1 From E-R Model to Relational Model
2 Entity type sid#name address house#street pcode Student
3 From E-R Model to Relational Model Entity type-----> Relational schema sid#name address house#street pcode Student sid# namehouse# street pcode Peter 10 Northfields Student
4 From E-R Model to Relational Model Entity type-----> Relational schema sid# namehouse# street pcode Peter 10 Northfields sid#name address house#street pcode Student
5 From E-R Model to Relational Model Entity type-----> Relational schema sid# namehouse# street pcode Peter 10 Northfields sid#name address house#street pcode Student Primary key
6 From E-R Model to Relational Model Instances of entities Kate Peter Paul Mary Student
7 From E-R Model to Relational Model Instances of entities----->Rows in relational table Instances of entities----->Rows in relational table Kate Peter Paul Mary sid# namehouse# street pcode 9205 Kate 10 Train Peter 123 Train Paul 34 Ross Mary 34 Ross 2056 Student
8 From E-R Model to Relational Model Multivalued attribute sid# name hobbies Student
9 From E-R Model to Relational Model Multivalued attribute---->Relational schema 9205 Kate 9307 Peter 9234 Paul 9326 Mary sid# name swimming painting pop music computers swimming gardening astronomy hobby sid# name hobbies Student
10 From E-R Model to Relational Model Multivalued attribute---->Relational schema 9205 Kate 9307 Peter 9234 Paul 9326 Mary sid# name 9205 swimming 9205 painting 9307 pop music 9234 computers 9234 swimming 9326 gardening 9326 astronomy sid# hobby sid# name hobbies Student
11 From E-R Model to Relational Model Multivalued attribute---->Relational schema sid# name hobbies Student 9205 Kate 9307 Peter 9234 Paul 9326 Mary sid# name 9205 swimming 9205 painting 9307 pop music 9234 computers 9234 swimming 9326 gardening 9326 astronomy sid# hobby
12 From E-R Model to Relational Model Multivalued attribute---->Relational schema sid# name hobbies Student 9205 Kate 9307 Peter 9234 Paul 9326 Mary sid# name 9205 swimming 9205 painting 9307 pop music 9234 computers 9234 swimming 9326 gardening 9326 astronomy sid# hobby
13 From E-R Model to Relational Model Multivalued attribute---->Relational schema 9205 Kate 9307 Peter 9234 Paul 9326 Mary sid# name 9205 swimming 9205 painting 9307 pop music 9234 computers 9234 swimming 9326 gardening 9326 astronomy sid# hobby sid# name hobbies Student Primary key
14 From E-R Model to Relational Model Multivalued attribute---->Relational schema 9205 Kate 9307 Peter 9234 Paul 9326 Mary sid# name 9205 swimming 9205 painting 9307 pop music 9234 computers 9234 swimming 9326 gardening 9326 astronomy sid# hobby sid# name hobbies Student Primary key Foreign key
15 From E-R Model to Relational Model Multivalued attribute---->Relational schema Do we really need two tables? Multivalued attribute---->Relational schema Do we really need two tables?
16 From E-R Model to Relational Model Multivalued attribute---->Relational schema Do we really need two tables? Multivalued attribute---->Relational schema Do we really need two tables? 9205 Kate swimming 9205 Kate painting 9307 Peter pop music 9234 Paul computers 9234 Paul swimming 9326 Mary gardening 9326 Mary astronomy sid# name hobby
17 From E-R Model to Relational Model Multivalued attribute---->Relational schema Do we really need two tables? Multivalued attribute---->Relational schema Do we really need two tables? 9205 Kate swimming 9205 Kate painting 9307 Peter pop music 9234 Paul computers 9234 Paul swimming 9326 Mary gardening 9326 Mary astronomy sid# name hobby Redundant !!!
18 From E-R Model to Relational Model Multivalued attribute---->Relational schema Do we really need two tables? Multivalued attribute---->Relational schema Do we really need two tables? 9205 Kate swimming 9205 Kate painting 9307 Peter pop music 9234 Paul computers 9234 Paul swimming 9326 Mary gardening 9326 Mary astronomy sid# name hobby YES ! We do !!! Redundant !!!
19 From E-R Model to Relational Model One-to-One Relationship Department Chairperson name building# manages title (0,1)(1,1)
20 From E-R Model to Relational Model One-to-One Relationship----->Relational schema One-to-One Relationship----->Relational schema Department Chairperson name building# manages title dname building# cname title ITACS 3 Joan Prof (0,1)(1,1)
21 From E-R Model to Relational Model One-to-One Relationship----->Relational schema One-to-One Relationship----->Relational schema Department Chairperson name building# manages title dname building# cname title ITACS 3 Joan Prof (0,1)(1,1) Primary key
22 From E-R Model to Relational Model One-to-One Relationship----->Relational schema One-to-One Relationship----->Relational schema Department Chairperson name building# manages title dname building# cname title ITACS 3 Joan Prof (0,1)(1,1) Primary key Candidate key
23 From E-R Model to Relational Model One-to-One Relationship----->Relational schema One-to-One Relationship----->Relational schema Department Chairperson name building# manages title dname building# cname title ITACS 3 Joan Prof (0,1)(1,1) Primary key Candidate key May be NULL
24 From E-R Model to Relational Model One-to-Many Relationship Employee Project works-on e#ename cdate budget title (1,1)(1,m)
25 From E-R Model to Relational Model One-to-Many Relationship---->Relational schemas One-to-Many Relationship---->Relational schemas Employee Project works-on e#ename cdate budget title (1,1)(1,m) 100 Peter 200 Paul 300 Mary e# ename SQL /12/99 ObjectBin /12/97 title budget cdate Employee Project
26 From E-R Model to Relational Model One-to-Many Relationship---->Relational schemas One-to-Many Relationship---->Relational schemas Employee Project works-on e#ename cdate budget title (1,1)(1,m) 100 Peter SQL Paul SQL Mary ObjectBin e# ename proj-title SQL /12/99 ObjectBin /12/97 title budget cdate Employee Project
27 From E-R Model to Relational Model One-to-Many Relationship---->Relational schemas One-to-Many Relationship---->Relational schemas Employee Project works-on e#ename cdate budget title (1,1)(1,m) 100 Peter SQL Paul SQL Mary ObjectBin e# ename proj-title SQL /12/99 ObjectBin /12/97 title budget cdate Employee Project
28 From E-R Model to Relational Model One-to-Many Relationship---->Relational schemas One-to-Many Relationship---->Relational schemas Employee Project works-on e#ename cdate budget title (1,1)(1,m) 100 Peter SQL Paul SQL Mary ObjectBin e# ename proj-title SQL /12/99 ObjectBin /12/97 title budget cdate Employee Project Primary key
29 From E-R Model to Relational Model One-to-Many Relationship---->Relational schemas One-to-Many Relationship---->Relational schemas Employee Project works-on e#ename cdate budget title (1,1)(1,m) 100 Peter SQL Paul SQL Mary ObjectBin e# ename proj-title SQL /12/99 ObjectBin /12/97 title budget cdate Employee Project Primary key Primary key
30 From E-R Model to Relational Model One-to-Many Relationship---->Relational schemas One-to-Many Relationship---->Relational schemas Employee Project works-on e#ename cdate budget title (1,1)(1,m) 100 Peter SQL Paul SQL Mary ObjectBin e# ename proj-title SQL /12/99 ObjectBin /12/97 title budget cdate Employee Project Primary key Primary key Foreign key
31 From E-R Model to Relational Model Many-to-Many relationship Supplier Parts supplies s#name p# (0,m)(0,n)
32 From E-R Model to Relational Model Many-to-Many relationship---> relational schemas Many-to-Many relationship---> relational schemas Supplier Parts supplies s#name p# (0,m)(0,n) Supplier Part s# name 100 John 200 Peter 300 Joan p# pname 10 bolt 20 nut 30 screw
33 From E-R Model to Relational Model Many-to-Many relationship---> relational schemas Many-to-Many relationship---> relational schemas SP s# p# Supplier Parts supplies s#name p# (0,m)(0,n) Supplier Part s# name 100 John 200 Peter 300 Joan p# pname 10 bolt 20 nut 30 screw
34 From E-R Model to Relational Model Many-to-Many relationship---> relational schemas Many-to-Many relationship---> relational schemas SP s# p# Supplier Parts supplies s#name p# (0,m)(0,n) Supplier Part s# name 100 John 200 Peter 300 Joan p# pname 10 bolt 20 nut 30 screw
35 From E-R Model to Relational Model Many-to-Many relationship---> relational schemas Many-to-Many relationship---> relational schemas SP s# p# Supplier Parts supplies s#name p# (0,m)(0,n) Supplier Part s# name 100 John 200 Peter 300 Joan p# pname 10 bolt 20 nut 30 screw Primary key
36 From E-R Model to Relational Model Many-to-Many relationship---> relational schemas Many-to-Many relationship---> relational schemas SP s# p# Supplier Parts supplies s#name p# (0,m)(0,n) Supplier Part s# name 100 John 200 Peter 300 Joan p# pname 10 bolt 20 nut 30 screw Primary key Primary key
37 From E-R Model to Relational Model Many-to-Many relationship---> relational schemas Many-to-Many relationship---> relational schemas SP s# p# Supplier Parts supplies s#name p# (0,m)(0,n) Supplier Part s# name 100 John 200 Peter 300 Joan p# pname 10 bolt 20 nut 30 screw Primary key Primary key Primary key
38 From E-R Model to Relational Model Many-to-Many relationship---> relational schemas Many-to-Many relationship---> relational schemas SP s# p# Supplier Parts supplies s#name p# (0,m)(0,n) Supplier Part s# name 100 John 200 Peter 300 Joan p# pname 10 bolt 20 nut 30 screw Primary key Primary key Primary key Foreign key
39 From E-R Model to Relational Model Many-to-Many relationship---> relational schemas Many-to-Many relationship---> relational schemas SP s# p# Supplier Parts supplies s#name p# (0,m)(0,n) Supplier Part s# name 100 John 200 Peter 300 Joan p# pname 10 bolt 20 nut 30 screw Primary key Primary key Primary key Foreign key Foreign key
40 From E-R Model to Relational Model Attributes describing relationship Supplier Parts supplies s#name p# (0,m)(0,n) quantity
41 From E-R Model to Relational Model Attributes describing relationship Supplier Parts supplies s#name p# (0,m)(0,n) SupplierSP Part s# name 100 John 200 Peter 300 Joan s# p# quantity p# pname 10 bolt 20 nut 30 screw quantity
42 From E-R Model to Relational Model Weak entity Airplane (1,n)(1,1) Seat has seat# position airplane# typeowner
43 From E-R Model to Relational Model Weak entity ---> relational schema airplane# type owner PL234 A303 LOT US124 B747 BTA WE222 B737 AF airplane# seat# position PL window PL aisle US window Airplane (1,n)(1,1) Seat has seat# position airplane# typeowner Airplane Seat
44 From E-R Model to Relational Model Weak entity ---> relational schema airplane# type owner PL234 A303 LOT US124 B747 BTA WE222 B737 AF airplane# seat# position PL window PL aisle US window Airplane (1,n)(1,1) Seat has seat# position airplane# typeowner Airplane Seat
45 From E-R Model to Relational Model Weak entity ---> relational schema airplane# type owner PL234 A303 LOT US124 B747 BTA WE222 B737 AF airplane# seat# position PL window PL aisle US window Airplane (1,n)(1,1) Seat has seat# position airplane# typeowner Primary key Airplane Seat
46 From E-R Model to Relational Model Weak entity ---> relational schema airplane# type owner PL234 A303 LOT US124 B747 BTA WE222 B737 AF airplane# seat# position PL window PL aisle US window Airplane (1,n)(1,1) Seat has seat# position airplane# typeowner Primary key Foreign key Airplane Seat
47 From E-R Model to Relational Model Weak entity ---> relational schema airplane# type owner PL234 A303 LOT US124 B747 BTA WE222 B737 AF airplane# seat# position PL window PL aisle US window Airplane (1,n)(1,1) Seat has seat# position airplane# typeowner Primary key Foreign key Primary key Airplane Seat
48 From E-R Model to Relational Model Generalization
49 From E-R Model to Relational Model Generalization ---> relational schema (1)
50 From E-R Model to Relational Model Undergraduate studentPostgraduate student s# name project group# supervisor Student Generalization ---> relational schema (1) Undergraduate studentPostgraduate student s# name project group# supervisor Student
51 From E-R Model to Relational Model Generalization ---> relational schema (1) Undergraduate studentPostgraduate student s# name project group# supervisor Student s#name pgroup#supervisortype 007James13NULLundergraduate 008JoanNULLPeterpostgraduate 009Mary14NULLundergraduate 010Michael15NULLundergraduate Student
52 From E-R Model to Relational Model Generalization ---> relational schema (1) s#name pgroup#supervisortype 007James13NULLundergraduate 008JoanNULLPeterpostgraduate 009Mary14NULLundergraduate 010Michael15NULLundergraduate Student Undergraduate studentPostgraduate student s# name project group# supervisor Student
53 From E-R Model to Relational Model Generalization ---> relational schema (1) s#name pgroup#supervisortype 007James13NULLundergraduate 008JoanNULLPeterpostgraduate 009Mary14NULLundergraduate 010Michael15NULLundergraduate Student Undergraduate studentPostgraduate student s# name project group# supervisor Student Primary key
54 From E-R Model to Relational Model Generalization ---> relational schemas (2) Undergraduate studentPostgraduate student s# name project group# supervisor Student
55 From E-R Model to Relational Model Generalization ---> relational schemas (2) Undergraduate studentPostgraduate student s# name project group# supervisor Student UStudent s#name pgroup#s#namesupervisor 007James13 008JoanPeter 009Mary14 010Michael15 PStudent
56 From E-R Model to Relational Model Generalization ---> relational schemas (2) Undergraduate studentPostgraduate student s# name project group# supervisor Student UStudent s#name pgroup#s#namesupervisor 007James13 008JoanPeter 009Mary14 010Michael15 PStudent Primary key
57 From E-R Model to Relational Model Generalization ---> relational schemas (3) Undergraduate studentPostgraduate student s# name project group# supervisor Student
58 From E-R Model to Relational Model Generalization ---> relational schemas (3) Undergraduate studentPostgraduate student s# name project group# supervisor Student PStudent s#names# pgroup#s#supervisor 007James Peter 008Joan 009Mary Michael01015 UStudent
59 From E-R Model to Relational Model Generalization ---> relational schemas (3) Undergraduate studentPostgraduate student s# name project group# supervisor Student PStudent s#names# pgroup#s#supervisor 007James Peter 008Joan 009Mary Michael01015 UStudent Primary key
60 From E-R Model to Relational Model Generalization ---> relational schemas (3) Undergraduate studentPostgraduate student s# name project group# supervisor Student PStudent s#names# pgroup#s#supervisor 007James Peter 008Joan 009Mary Michael01015 UStudent Primary key Foreign key
61 From E-R Model to Relational Model Bibliography P. O’Neil, Database - Principles, Programming, Performance, chapters 5.1, 5.2, 5.3 R. Elmasri, S.B. Navathe, Fundamentals of Database Systems, chapter 21.1, 21.2 Bibliography P. O’Neil, Database - Principles, Programming, Performance, chapters 5.1, 5.2, 5.3 R. Elmasri, S.B. Navathe, Fundamentals of Database Systems, chapter 21.1, 21.2