12
Transforming Entity-Relationship Models Into Relational Database Implementations

Transforming Entity-Relationship Models Into Relational Database Implementations

  • Upload
    powa

  • View
    19

  • Download
    0

Embed Size (px)

DESCRIPTION

Transforming Entity-Relationship Models Into Relational Database Implementations. Two Simple Rules for Transforming an ERD into Tables. Every entity will be a table. A relationship will be a table only if: It is a many to many relationship or It has its own attributes. - PowerPoint PPT Presentation

Citation preview

Page 1: Transforming Entity-Relationship Models Into Relational Database Implementations

Transforming Entity-Relationship Models Into Relational Database Implementations

Page 2: Transforming Entity-Relationship Models Into Relational Database Implementations

Two Simple Rules forTransforming 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

orb. It has its own attributes.

Page 3: Transforming Entity-Relationship Models Into Relational Database Implementations

Placement of Foreign KeysIn 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.

Page 4: Transforming Entity-Relationship Models Into Relational Database Implementations

Binary One to Many

PUBLISHER ( Pnum, Name, Addr )

BOOK ( ISBN, Title, Edition, Pnum )

Page 5: Transforming Entity-Relationship Models Into Relational Database Implementations

Binary One to One

STATE ( Code, Name, Size )

GOVERNOR ( SSN, Name, BDate, Code )

or

STATE ( Code, Name, Size , SSN )

GOVERNOR ( SSN, Name, BDate )

Page 6: Transforming Entity-Relationship Models Into Relational Database Implementations

Binary Many to Many

STUDENT ( Snum, Name, Addr )

COURSE ( Cnum, CTitle, CrHrs )

TAKES ( Snum, Cnum, Term )

Page 7: Transforming Entity-Relationship Models Into Relational Database Implementations

Unary One to One

EMPLOYEE ( Enum, Name, SpouseEnum )

Page 8: Transforming Entity-Relationship Models Into Relational Database Implementations

Unary One to Many

EMPLOYEE ( Enum, Name, MgrEnum )

Page 9: Transforming Entity-Relationship Models Into Relational Database Implementations

Unary Many to Many

PART ( Pnum, Name )

ASSEMBLY ( Anum, Pnum )

Page 10: Transforming Entity-Relationship Models Into Relational Database Implementations

Ternary

PART ( Pnum, Pname )

SUPPLIER ( Snum, SName)

WAREHOUSE ( Wnum, City )

SHIPSTO ( Pnum, Snum, WNum )

Page 11: Transforming Entity-Relationship Models Into Relational Database Implementations

Composite Entity

STUDENT ( Snum, Name, Addr )

COURSE ( Cnum, CTitle, CrHrs )

TAKES ( Enum, Snum, Cnum, Term )

Page 12: Transforming Entity-Relationship Models Into Relational Database Implementations

Supertype-Subtype

STUDENT ( PID, Major )

GRADUATE ( PID, Thesis )

UNDERGRADUATE ( PID, Hours )