Presentation is loading. Please wait.

Presentation is loading. Please wait.

Transformation of E/R Diagram to Relation

Similar presentations


Presentation on theme: "Transformation of E/R Diagram to Relation"— Presentation transcript:

1 Transformation of E/R Diagram to Relation

2 Transformation of E/R Diagram to Relation
Primary keys allow entity sets and relationship sets to be expressed uniformly as relations E/R diagram  collection of tables For each entity set and each relationship set there is a unique table CSCE 520 11/16/2018

3 Transformation from E/R to Relation
Entity set: becomes a relation with the attributes of the entity set Relationship: becomes a relation with attributes: Key of connected entity sets Attributes of the relationship CSCE 520 11/16/2018

4 Example E/R Diagram Dog Kennel Owner Breed Name Name License # Boards
Age Address Owns Phone Weight Pays Owner Amount Name Phone CSCE 520 11/16/2018

5 Entity Set to Relation Dog Dog(Name,Breed,Age,Weight) Breed Name Age
CSCE 520 11/16/2018

6 Entity Set to Relation Kennel Owner
Name Amount Date Name Address Kennel Pays Owner Phone Pays(Kennel. Name,Owner.Name,Amount,Date) CSCE 520 11/16/2018

7 Combining Relations: Many-One
Name Amount Date Name Address Kennel Pays Owner Phone Favorite Combine relation for entity of “many” side (Owner) with relationship set, i.e., Owner’s-favorite(Name,Phone,FavoriteKennel.Name) CSCE 520 11/16/2018

8 Combining Relations: Many-Many
Name Name Address Kennel Pays Owner Phone Combining Owner with pays: Owner(Kennel.Name,Owner.Name,Phone) CSCE 520 11/16/2018

9 Many-many Relationship
Kennel Name Owner Name Owner Phone White Oak Mary Little Creek Viki Joe Redundancy 11/16/2018 CSCE 520

10 Weak Entity Sets to Relation
Relation for a weak entity set must include attributes for its complete key (including those that belong to other entities) as well as its own, non-key attributes Supporting relationship is redundant and does not yield a relation CSCE 520 11/16/2018

11 Example: Weak Entity Set
Breed Name Name Dog Owns Owner Phone Age Owner(Owner.Name, Phone) Dog(Dog.Name,Owner.Name, Age,Breed) Owns(Dog.Name,Owner.Name1,Owner.Name2) Already in Dog Redundant! Must be the same CSCE 520 11/16/2018

12 Entity Sets with Subclasses
Three approaches: Object-oriented: each entity belongs to exactly one class. Create a relation for each class with all its attributes. E/R style: create one relation for each subclass with only the key attributes and the attributes of the subclass. Entity is represented in all relations to whose subclass entity set it belongs. Null values: create on relation with all attributes. Entities have null values in attributes that do not belong to them. CSCE 520 11/16/2018

13 Example Subclass Name Breed Dog ISA Show-Dog Rank CSCE 520 11/16/2018

14 Object-Oriented Approach
Name Breed Buddy Mix Dog Name Breed Rank Pepper Germanshepherd 1st Show dog CSCE 520 11/16/2018

15 E/R Approach Name Breed Pepper Germanshepherd Buddy Mix Name Rank
Dog Name Rank Pepper 1st Show dog CSCE 520 11/16/2018

16 Null Values Name Breed Rank Buddy Mix NULL Pepper Germanshepherd 1st
Dog CSCE 520 11/16/2018

17 Comparisons Object-Oriented: good for queries like “find all G.S. dogs that ranked 2nd or above”. E/R: good for “find all G.S. dogs (regardless of being a show dog or not) Null values: may save space, but not good if too many attributes with null values. CSCE 520 11/16/2018


Download ppt "Transformation of E/R Diagram to Relation"

Similar presentations


Ads by Google