extracting tables from erd. a table example t1 = (foo,bar,baz,{x,y}) t2 = (quz,bar,foo,{y,z}) t1[a1]...
TRANSCRIPT
![Page 1: 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̅]](https://reader036.vdocument.in/reader036/viewer/2022082709/56649cf45503460f949c1c99/html5/thumbnails/1.jpg)
Extracting Tables from ERD
![Page 2: 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̅]](https://reader036.vdocument.in/reader036/viewer/2022082709/56649cf45503460f949c1c99/html5/thumbnails/2.jpg)
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)
a2 a1 k2 k1
{x,y} baz bar foo
{y,z} foo bar quz
t1
t2
k' = (k1,k2)a% = (a1,a2)
Vector of all key attributes
Vector of all non-key
attributes
![Page 3: 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̅]](https://reader036.vdocument.in/reader036/viewer/2022082709/56649cf45503460f949c1c99/html5/thumbnails/3.jpg)
Entities
• A short representation:
E
k1 kn a1 am
k' = (k1,…,kn) a% = (a1,…,am)
E
k' a%
![Page 4: 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̅]](https://reader036.vdocument.in/reader036/viewer/2022082709/56649cf45503460f949c1c99/html5/thumbnails/4.jpg)
Entities
• Translation to a table:a̅� k
am … a1 kn … k1
E
k' a%
• Constraints:t1[k] = t2[k] t⇒ 1[a%] = t2[a%]
![Page 5: 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̅]](https://reader036.vdocument.in/reader036/viewer/2022082709/56649cf45503460f949c1c99/html5/thumbnails/5.jpg)
Entities
• We assume k' can not be empty• a% may be empty
E
k' a%
![Page 6: 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̅]](https://reader036.vdocument.in/reader036/viewer/2022082709/56649cf45503460f949c1c99/html5/thumbnails/6.jpg)
Entities
• Any ai 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 ai: t[ai] D∈
– for a multi-valued attribute aj: t[aj] P(D) ∈• a powerset.
E
k1 kn a1 am
ai
![Page 7: 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̅]](https://reader036.vdocument.in/reader036/viewer/2022082709/56649cf45503460f949c1c99/html5/thumbnails/7.jpg)
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
genre year name
Drama 2003 Cold Mountain
k
screenshots year name
screenshot1 2003 Cold Mountain
![Page 8: 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̅]](https://reader036.vdocument.in/reader036/viewer/2022082709/56649cf45503460f949c1c99/html5/thumbnails/8.jpg)
Relationships
• Each k', a% may be empty• Translation to a table:
E1
k'1 a%1
k'2 a%R k'R k'1
R E2
k'R a%R k'2 a%2
![Page 9: 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̅]](https://reader036.vdocument.in/reader036/viewer/2022082709/56649cf45503460f949c1c99/html5/thumbnails/9.jpg)
Relationships
• Constraints:– πk2(E2) π⊆ k2(R)
– πk2(R) π⊆ k2(E2) (true for a̅ny relationship!)
– πk1(R) π⊆ k1(E1) (true for a̅ny relationship!)
E1
k'1 a%1
R E2
k'R a%R k'2 a%2
![Page 10: 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̅]](https://reader036.vdocument.in/reader036/viewer/2022082709/56649cf45503460f949c1c99/html5/thumbnails/10.jpg)
Aggregations
• Turns the relationship into an entity with attributes of the relationship
E1
k'1 a%1
R E2
k'R a%R k'2 a%2
ER
E3
k'3 a%3
Sk'S
a%S
![Page 11: 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̅]](https://reader036.vdocument.in/reader036/viewer/2022082709/56649cf45503460f949c1c99/html5/thumbnails/11.jpg)
AggregationsE1:
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:
![Page 12: 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̅]](https://reader036.vdocument.in/reader036/viewer/2022082709/56649cf45503460f949c1c99/html5/thumbnails/12.jpg)
Example
Network.name traker.name
tracking
intrested1
cause User.name Network.name traker.name
user
name Birth_date
connected network
name type
tracker
name country
interested1cause tracking
![Page 13: 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̅]](https://reader036.vdocument.in/reader036/viewer/2022082709/56649cf45503460f949c1c99/html5/thumbnails/13.jpg)
Weak EntitiesTranslation to tables:
E1k'1a%1
a%1 k'1
E2k'2a%2
E3k'3a%3
a%2 k'2 k'1
a%3 k'3 k'2 k'1
![Page 14: 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̅]](https://reader036.vdocument.in/reader036/viewer/2022082709/56649cf45503460f949c1c99/html5/thumbnails/14.jpg)
Weak Entities
Constraints:πk1(E2) ⊆ πk1(E1)
πk1,k2(E3) π⊆ k1,k2(E2)
E1k'1a%1
E2k'2a%2
E3k'3a%3
![Page 15: 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̅]](https://reader036.vdocument.in/reader036/viewer/2022082709/56649cf45503460f949c1c99/html5/thumbnails/15.jpg)
Example
Address na̅me
Haifa, Hagalil 2 company1
Number na̅me
1 company1
2 company1
companyname1
Address
DepartmentNumber
![Page 16: 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̅]](https://reader036.vdocument.in/reader036/viewer/2022082709/56649cf45503460f949c1c99/html5/thumbnails/16.jpg)
ISA
• ISA – a branching weak entity without key components in the subclass
E1
k'1 a%1
E2a%2 E3 a%3
ISA
superclass
subclasssubclass
![Page 17: 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̅]](https://reader036.vdocument.in/reader036/viewer/2022082709/56649cf45503460f949c1c99/html5/thumbnails/17.jpg)
ISA – Translations and ConstraintsDessert:
Ice cream:
Cake:
Constraints:πname(Cake) π⊆ name(Dessert)
πname(Ice cream) π⊆ name(Dessert)
calories name
flavor name
type name
Dessert
name calories
Ice cream
flavor
Cake
type
ISA ISA
![Page 18: 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̅]](https://reader036.vdocument.in/reader036/viewer/2022082709/56649cf45503460f949c1c99/html5/thumbnails/18.jpg)
Exclusive ISAIce cream:
Sorbet:Frozen_yogurt:
Constraints:πname(Sorbet) π⊆ name(Ice cream)
πname(Frozen_yogurt) π⊆ name(Ice cream)
πna̅me(Sorbet)∩πna̅me(Frozen_yogurt)=∅
Ice cream
name calories
Sorbet
fruit
Frozen_yogurt
additions
ISA
calories name
fruit name
additions name
![Page 19: 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̅]](https://reader036.vdocument.in/reader036/viewer/2022082709/56649cf45503460f949c1c99/html5/thumbnails/19.jpg)
Covering All ISAIce cream:
Sorebt:
Frozen_yogurt:
Constraints:πname(Sorbet)∩πname(Frozen_yogurt)=∅
Ice cream
Name Calories
Sorbet
fruit
Frozen_yogurt
additions
ISA Thick lines
NO Table!
fruit calories name
additions calories name