| marp | true |
|---|---|
| title | SQL in the shell |
| description | Relationenalgebra auf der Kommandozeile |
| theme | terminal |
| paginate | true |
| _paginate | false |
| class | invert |
| id | name | stadt |
|---|---|---|
| 1 | Mueller GmbH | Berlin |
| 2 | Schmidt AG | Hamburg |
- Attribut: Spalte (id, name, stadt)
- Tupel: Zeile (1, Mueller GmbH, Berlin)
- Projektion
- Selektion
- Vereinigung
- Differenz
- Umbenennung
- Kartesisches Produkt
$$ R = \text{Relation über} {A_1, …, A_k} \text{ und }β ⊆ {A_1, …, A_k}. $$
$$ \pi_{\beta}(R):={t_{\beta}|t \in R} $$
$$ \sigma_{\text{A}}(R) := { t | t \in R \wedge t \text{ erf"ullt A} } $$
SELECT * FROM Customers
WHERE Country LIKE '%ada%';
$$ R \cup S := { t | t \in R \lor t \in S } $$
SELECT * FROM Customers_A
UNION
SELECT * FROM Customers_B;
$$ R \setminus S := { t | t \in R \land t \notin S } $$
SELECT * FROM Customers_A
EXCEPT
SELECT * FROM Customers_B;
$$ \rho_{[\mathrm{neu}\leftarrow\mathrm{alt}]}(R):= {t'|t'(R-\mathrm{alt})=t(R-\mathrm{alt}) \land t'(\mathrm{neu})=t(\mathrm{alt})} $$
awk -F ',' '{print $2, $1}' R
$$ R\times S:={(a_1,a_2,...,a_n,b_1,b_2,...,b_m)| \\ (a_1,...,a_n)\in R\wedge (b_1,...,b_m)\in S} $$
SELECT * FROM R, S;Kartesisches Produkt Selektion Projektion
cat · sed · grep · cut · awk · join · comm · diff · uniq · sort
"Do one thing and do it well"
"Relational algebra can turn any shell into a respectable database."
Matt Might - SQL in the Shell
Martin Funk · @eigenfunk