diff options
Diffstat (limited to 'ws2015')
-rw-r--r-- | ws2015/dbs/blaetter/06/abgabe.md | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/ws2015/dbs/blaetter/06/abgabe.md b/ws2015/dbs/blaetter/06/abgabe.md new file mode 100644 index 0000000..26a069b --- /dev/null +++ b/ws2015/dbs/blaetter/06/abgabe.md | |||
@@ -0,0 +1,63 @@ | |||
1 | --- | ||
2 | header-includes: | ||
3 | - \lstset{frame=single, breaklines=true, postbreak=\raisebox{0ex}[0ex][0ex]{\ensuremath{\color{red}\hookrightarrow\space}}} | ||
4 | --- | ||
5 | |||
6 | # Anfragen im Tupel- und Bereichskalkül | ||
7 | |||
8 | a) | ||
9 | \begin{align*} | ||
10 | & \left \{ name, nummer, bestand \mid \text{Artikel}(nummer, namme, \_, preis, bestand, \_) \land preis \leq 1000 \land bestand \geq 450 \right \} \\ | ||
11 | & \left \{ a.name, a.nummer, a.bestand \mid \text{Artikel}(a) \land a.preis \leq 1000 \land a.bestand \geq 450 \right \} | ||
12 | \end{align*} | ||
13 | |||
14 | b) | ||
15 | \begin{align*} | ||
16 | & \left \{ name_A, name_L, jahr \mid \text{Abteilung}(\_, name_A, \_, \_, leiter) \land \text{Angestellter}(leiter, name_L, \_, \_, jahr, \_) \right \} \\ | ||
17 | & \left \{ a.name, l.name, l.geburtsjahr \mid \text{Abteilung}(a) \land \text{Angestellter}(l) \land a.leiter = l.nummer \right \} | ||
18 | \end{align*} | ||
19 | |||
20 | c) | ||
21 | \begin{align*} | ||
22 | \{ nummer_A & \mid & \text{Artikel}(nummer_A, \_, abteilung, \_, \_, \_) \\ | ||
23 | & \land & \text{Abteilung}(abteilung, \_, \_, \_, leiter) \\ | ||
24 | & \land & \text{Angestellter}(leiter, \text{"Edgar F. Codd"}, \_, \_, \_, \_) \\ | ||
25 | & & \} | ||
26 | \end{align*} | ||
27 | \begin{align*} | ||
28 | \{ a & \mid & \text{Artikel}(a) \\ | ||
29 | & \land & \text{Abteilung}(a^\prime) \\ | ||
30 | & \land & \text{Angestellter}(l) \\ | ||
31 | & \land & a.abteilung = a^\prime.nummer \\ | ||
32 | & \land & a^\prime.leiter = l.nummer \\ | ||
33 | & \land & l.name = \text{"Edgar F. Codd"} \\ | ||
34 | & & \} | ||
35 | \end{align*} | ||
36 | |||
37 | # Join-Operationen in SQL | ||
38 | |||
39 | a) | ||
40 | |||
41 | ~~~ {.sql} | ||
42 | SELECT * FROM T1, T2 | ||
43 | ~~~ | ||
44 | |||
45 | b) | ||
46 | |||
47 | ~~~ {.sql} | ||
48 | SELECT * FROM T1, T2 WHERE T1.id = T2.id | ||
49 | ~~~ | ||
50 | |||
51 | c) (Hier) identisch zu (b). | ||
52 | |||
53 | d) | ||
54 | |||
55 | ~~~ {.sql} | ||
56 | SELECT * FROM T1 RIGHT JOIN T2 ON T1.id = T2.id | ||
57 | ~~~ | ||
58 | |||
59 | e) | ||
60 | |||
61 | ~~~ {.sql} | ||
62 | SELECT * FROM T1 LEFT JOIN T2 ON T1.id = T2.id | ||
63 | ~~~ | ||