Presentation on theme: "Transforming Entity-Relationship Models Into Relational Database Implementations."— Presentation transcript:
Transforming Entity-Relationship Models Into Relational Database Implementations
Two Simple Rules for Transforming an ERD into Tables 1.Every entity will be a table. 2.A relationship will be a table only if: a.It is a many to many relationship or b.It has its own attributes.
Placement of Foreign Keys In a Transformation One to Many: The primary key from “One” table is used as the foreign key in the “Many” table. One to One: The primary key from one of the “One” table is used as the foreign key in the other “One” table. Many to Many: The relationship becomes a “bridge” table and the primary key from each of the “Many” tables is used as a foreign key. All of the foreign keys collectively become the composite primary key of the new linking table.
Binary One to Many PUBLISHER ( Pnum, Name, Addr ) BOOK ( ISBN, Title, Edition, Pnum )
Binary One to One STATE ( Code, Name, Size ) GOVERNOR ( SSN, Name, BDate, Code ) or STATE ( Code, Name, Size, SSN ) GOVERNOR ( SSN, Name, BDate )
Binary Many to Many STUDENT ( Snum, Name, Addr ) COURSE ( Cnum, CTitle, CrHrs ) TAKES ( Snum, Cnum, Term )
Unary One to One EMPLOYEE ( Enum, Name, SpouseEnum )
Unary One to Many EMPLOYEE ( Enum, Name, MgrEnum )
Unary Many to Many PART ( Pnum, Name ) ASSEMBLY ( Anum, Pnum )