INTRODUCTION TO RELATIONAL DATABASE SYSTEMS
DATENBANKSYSTEME 1 (INF 3131)
Torsten Grust Universität Tübingen Winter 2015/16
1
INTRODUCTION TO RELATIONAL DATABASE SYSTEMS DATENBANKSYSTEME 1 (INF - - PowerPoint PPT Presentation
INTRODUCTION TO RELATIONAL DATABASE SYSTEMS DATENBANKSYSTEME 1 (INF 3131) Torsten Grust Universitt Tbingen Winter 2015/16 1 LEGO BUILDING INSTRUCTIONS Each LEGO set comes with building instructions , an illustrated booklet that
1
2
Page 25 in Building Instruction for LEGO Set 9495 (Y-Wing)
3
instructions set set step step piece piece color color quantity quantity page page img img width width height height
7 3010 2 2 24 ⟨image07⟩ 639 533 9495–1 7 3023 2 2 24 ⟨image07⟩ 639 533 9495–1 7 2877 86 1 24 ⟨image07⟩ 639 533 9495–1 8 3002 7 2 24 ⟨image08⟩ 650 522 9495–1 8 30414 1 2 24 ⟨image08⟩ 650 522 9495–1 9 30414 85 1 25 ⟨image09⟩ 541 638 9495–1 9 3062b 85 2 25 ⟨image09⟩ 541 638 9495–1 10 30033 11 1 25 ⟨image10⟩ 540 662 9495–1 10 2412b 86 1 25 ⟨image10⟩ 540 662 9495–1 10 4589b 86 2 25 ⟨image10⟩ 540 662 9495–1 10 87580 85 1 25 ⟨image10⟩ 540 662 9495–1 11 3039 2 1 25 ⟨image11⟩ 1042 558 9495–1 11 4073 85 4 25 ⟨image11⟩ 1042 558 9495–1 11 44728 3 1 25 ⟨image11⟩ 1042 558
5
6
7
instructions set set step step piece piece color color quantity quantity page page img img width width height height
7 3010 2 2 24 ⟨image07⟩ 639 533 9495–1 7 3023 2 2 24 ⟨image07⟩ 639 533 9495–1 7 2877 86 1 24 ⟨image07⟩ 639 533 9495–1 8 3002 7 2 24 ⟨image08⟩ 650 522 9495–1 8 30414 1 2 24 ⟨image08⟩ 650 522 9495–1 9 30414 85 1 25 ⟨image09⟩ 541 638 9495–1 9 3062b 85 2 25 ⟨image09⟩ 541 638
8
SELECT DISTINCT 'The FD { b1, …, bn } c does not hold' FROM R GROUP BY b1, …, bn HAVING COUNT(DISTINCT c) > 1
⟨aggregate⟩([ ALL ] ⟨expression⟩) -- aggregate all non-NULL values ⟨aggregate⟩(DISTINCT ⟨expression⟩) -- aggregate all distinct non-NULL values ⟨aggregate⟩(*) -- aggregate all rows (count(*))
9
10
set set step step page page
24 9495–1 8 24 9495–1 9 25 9495–1 10 25 9495–1 11 25
11
store store city city state state country country
HAMBURG Hamburg Germany 8 LEIPZIG Sachsen Germany 9 MÜNCHEN Bayern Germany 10 MÜNCHEN PASING Bayern Germany 11 NÜRNBERG Bayern Germany
ARDEN FAIR MALL CA USA 17 DISNEYLAND RESORT CA USA 18 FASHION VALLEY CA USA
12
users user user rating rating stars stars Alex 3 *** Bert 1 * Cora 4 **** Drew 5 ***** Erik 1 * Fred 3 ***
13
CREATE [ OR REPLACE ] [ TEMPORARY ] VIEW ⟨name⟩ AS ⟨query⟩
14
ALTER TABLE users DROP COLUMN stars;
CREATE TEMPORARY VIEW users(user, rating, stars) AS SELECT u.user, u.rating, repeat('*', u.rating) stars FROM users u;
15
16
17
18
instructions set set step step piece piece color color quantity quantity page page img img width width height height
19
(Input: FD set , Output: set of all candidate keys for ) If then Return [ Invariant: ] else For each do If then [ Is essential for the key? ] ⚑ else Return
key(K, U, F) F R
‐
U = ∅ {K} cover(K ∪ U, F) = sch(R)
‐ X := ∅ ‐
c ∈ U
‐
c ∉ cover(K ∪ (U ∖ {c}), F) c
‐ X := X ∪ key(K ∪ {c}, U ∖ {c}, F) ‐ X := X ∪ key(K, U ∖ {c}, F) ‐
X
20
21
22
instructions set set step step piece piece color color quantity quantity page page img img width width height height
23
24
instructions set set step step piece piece color color quantity quantity page page img img width width height height
users name name rating rating stars stars
stores store store city city state state country country
25
) R1
) R2
26
users ( ) user user rating rating Alex 3 Bert 1 Cora 4 Drew 5 Erik 1 Fred 3 render ( ) rating rating stars stars 1 * 3 *** 4 **** 5 ******
R1 R2
27
R A A B B C C a₁ b₁ c₁ a₁ b₁ c₂ a₁ b₂ c₁
A A B B C C a₁ b₁ c₁ a₁ b₁ c₂ a₁ b₂ c₁ a₁ b₂ c2 ⚠
28
29
zipcodes zip zip street street city city state state
30
31