Download presentation
Presentation is loading. Please wait.
Published byLewis Conley Modified over 9 years ago
2
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 11/15/2015CSCE 5202
3
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 11/15/2015CSCE 5203
4
11/15/2015CSCE 5204 Example E/R Diagram Dog Name Breed Age License # Phone Weight Name Phone Address Owns Owner Kennel Pays Boards Amount
5
11/15/2015CSCE 5205 Entity Set to Relation Dog Name Breed Age Weight Dog(Name,Breed,Age,Weight)
6
11/15/2015CSCE 5206 Entity Set to Relation OwnerKennel Pays AmountName Address Pays(Kennel. Name,Owner.Name,Amount,Date) Phone Date
7
11/15/2015CSCE 5207 Combining Relations: Many-One OwnerKennel Pays Amount Name Address Combine relation for entity of “many” side (Owner) with relationship set, i.e., Owner’s-favorite(Name,Phone,FavoriteKennel.Name) Favorite Phone Date
8
11/15/2015CSCE 5208 Combining Relations: Many-Many OwnerKennel Pays Name Address Combining Owner with pays: Owner(Kennel.Name,Owner.Name,Phone) Phone
9
Kennel Name Owner Name Owner Phone White OakMary890-4421 Little CreekMary890-4421 White OakViki987-4456 White OakJoe334-2234 11/15/2015CSCE 5209 Redundancy
10
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 11/15/2015CSCE 52010
11
11/15/2015CSCE 52011 Dog Name Breed Age Owner Owns Name Phone Owner(Owner.Name, Phone) Dog(Dog.Name,Owner.Name, Age,Breed) Owns(Dog.Name,Owner.Name1,Owner.Name2) Must be the same Already in Dog Redundant!
12
Three approaches: 1. Object-oriented: each entity belongs to exactly one class. Create a relation for each class with all its attributes. 2. 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. 3. Null values: create on relation with all attributes. Entities have null values in attributes that do not belong to them. 11/15/2015CSCE 52012
13
11/15/2015CSCE 52013 Example Subclass Dog NameBreed Show-Dog Rank ISA
14
11/15/2015CSCE 52014 Object-Oriented Approach NameBreed BuddyMix NameBreedRank PepperGermanshepherd1st Dog Show dog
15
11/15/2015CSCE 52015 NameBreed PepperGermanshepherd BuddyMix NameRank Pepper1st Dog Show dog
16
11/15/2015CSCE 52016 Null Values NameBreedRank BuddyMixNULL PepperGermanshepherd1st Dog
17
Object-Oriented: good for queries like “find all G.S. dogs that ranked 2 nd 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. 11/15/2015CSCE 52017
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.