Presentation is loading. Please wait.

Presentation is loading. Please wait.

Extracting Tables from ERD. A Table Example t1 = (foo,bar,baz,{x,y}) t2 = (quz,bar,foo,{y,z}) t1[a1] = (baz) t2[a2] = ({y,z}) t1[a̅] = (baz,{x,y}) t2[k̅]

Similar presentations


Presentation on theme: "Extracting Tables from ERD. A Table Example t1 = (foo,bar,baz,{x,y}) t2 = (quz,bar,foo,{y,z}) t1[a1] = (baz) t2[a2] = ({y,z}) t1[a̅] = (baz,{x,y}) t2[k̅]"— Presentation transcript:

1 Extracting Tables from ERD

2 A Table Example t1 = (foo,bar,baz,{x,y}) t2 = (quz,bar,foo,{y,z}) t1[a1] = (baz) t2[a2] = ({y,z}) t1[a̅] = (baz,{x,y}) t2[k̅] = (quz,bar) a2a1k2k1 {x,y}bazbarfoo {y,z}foobarquz t1 t2 k̅ = (k1,k2) a̅ = (a1,a2) Vector of all key attributes Vector of all non-key attributes

3 Entities A short representation: E k1kna1am k̅ = (k1,…,kn)a̅ = (a1,…,am) E k̅a̅

4 Entities Translation to a table: a̅k̅ am…a1kn…k1 E k̅a̅ Constraints: t 1 [k̅] = t 2 [k̅] ⇒ t 1 [a̅] = t 2 [a̅]

5 Entities We assume k̅ can not be empty a̅ may be empty E k̅a̅

6 Entities Any a i may be multi-valued – Multi-valued attributes cannot be a part of the key In domain D, for a table row t: – for an attribute a i : t[a i ] ∈ D – for a multi-valued attribute a j : t[a j ] ∈ P(D) a powerset. E k1kna1am aiai

7 Another Representation of a Multi-Valued Attribute A table without multi-valued attributes: Tables - one for each multi-valued attribute: Specifically for screenshots a power set won't work well movie name year screenshots genre a̅k̅ genreyearname Drama2003Cold Mountain k̅ screenshotsyearname screenshot12003Cold Mountain

8 Relationships Each k̅, a̅ may be empty Translation to a table: E1E1 k̅ 1 a̅ 1 k̅ 2 a̅ R k̅ R k̅ 1 R E2E2 k̅ R a̅ R k̅ 2 a̅ 2

9 Relationships Constraints: – π k2 (E 2 ) ⊆ π k2 (R) – π k2 (R) ⊆ π k2 (E 2 ) (true for any relationship!) – π k1 (R) ⊆ π k1 (E 1 ) (true for any relationship!) E1E1 k̅ 1 a̅ 1 R E2E2 k̅ R a̅ R k̅ 2 a̅ 2

10 Aggregations Turns the relationship into an entity with attributes of the relationship E1E1 k̅ 1 a̅ 1 R E2E2 k̅ R a̅ R k̅ 2 a̅ 2 ERER E3E3 k̅ 3 a̅ 3 S k̅ S a̅ S

11 Aggregations E1: E2: E3: a̅ 1 k̅ 1 a̅ 2 k̅ 2 a̅ 3 k̅ 3 a̅ R k̅ R k̅ 2 k̅ 1 a̅ S k̅ S k̅ R k̅ 3 k̅ 2 k̅ 1 R: S:

12 Example Network.nametraker.name tracking intrested1 causeUser.nameNetwork.nametraker.name user nameBirth_date connected network nametype tracker namecountry interested1 cause tracking

13 Weak Entities Translation to tables: E1E1 k̅ 1 a̅ 1 k̅ 1 E2E2 k̅ 2 a̅ 2 E3E3 k̅ 3 a̅ 3 a̅ 2 k̅ 2 k̅ 1 a̅ 3 k̅ 3 k̅ 2 k̅ 1

14 Weak Entities Constraints: π k1 (E 2 ) ⊆ π k1 (E 1 ) π k1,k2 (E 3 ) ⊆ π k1,k2 (E 2 ) E1E1 k̅ 1 a̅ 1 E2E2 k̅ 2 a̅ 2 E3E3 k̅ 3 a̅ 3

15 Example Addressname Haifa, Hagalil 2company1 Numbername 1company1 2 company name 1 Address Department Number

16 ISA ISA – a branching weak entity without key components in the subclass E1E1 k̅ 1 a̅ 1 E2E2 a̅ 2 E3E3 a̅ 3 ISA superclass subclass

17 ISA – Translations and Constraints Dessert: Ice cream: Cake: Constraints: π name (Cake) ⊆ π name (Dessert) π name (Ice cream) ⊆ π name (Dessert) caloriesname flavorname typename Dessert namecalories Ice cream flavor Cake type ISA

18 Exclusive ISA Ice cream: Sorbet: Frozen_yogurt: Constraints: π name (Sorbet) ⊆ π name (Ice cream) π name (Frozen_yogurt) ⊆ π name (Ice cream) π name (Sorbet)∩π name (Frozen_yogurt)= ∅ Ice cream namecalories Sorbet fruit Frozen_yogurt additions ISA caloriesname fruitname additionsname

19 Covering All ISA Ice cream: Sorebt: Frozen_yogurt: Constraints: π name (Sorbet)∩π name (Frozen_yogurt)= ∅ Ice cream NameCalories Sorbet fruit Frozen_yogurt additions ISA Thick lines NO Table! fruitcaloriesname additionscaloriesname


Download ppt "Extracting Tables from ERD. A Table Example t1 = (foo,bar,baz,{x,y}) t2 = (quz,bar,foo,{y,z}) t1[a1] = (baz) t2[a2] = ({y,z}) t1[a̅] = (baz,{x,y}) t2[k̅]"

Similar presentations


Ads by Google