Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS422 Principles of Database Systems From ER to Relations Chengyu Sun California State University, Los Angeles Adapted from Jeffrey Ullman’s lecture notes.

Similar presentations


Presentation on theme: "CS422 Principles of Database Systems From ER to Relations Chengyu Sun California State University, Los Angeles Adapted from Jeffrey Ullman’s lecture notes."— Presentation transcript:

1 CS422 Principles of Database Systems From ER to Relations Chengyu Sun California State University, Los Angeles Adapted from Jeffrey Ullman’s lecture notes at http://www-db.stanford.edu/~ullman/dscb.html

2 Relation NameManufacturer Winter BrewPete’s Bud LiteAnheuser-Busch Attributes (fields) Tuples (Records) (Rows) Beers Relation schema: Beers( name, manufacturer ) orBeers( name:string, manufacturer:string)

3 About Relational Model Attributes values must be atomic No order among attributes No order among tuples

4 Convert ER Diagram to Relations Entity sets Relationships Weak entity sets Subclasses

5 Entity Sets Drinkers nameaddr Beers namemanf Drinkers( name, addr ) Beers( name, manf )

6 Relationships DrinkersBeersLikes Favorite Married husband wife name addr name manf Buddies 1 2 ??

7 Converting Relationships – General Rules The resulting relation includes All key attributes from the entity sets involved in the relationship All the attributes of the relationship itself

8 Combining Relations Drinkers Beers Favorite Likes Drinkers and Likes ?? Drinkers and Favorite ?? Beers and Likes ?? Beers and Favorite ??

9 Converting Relationships – Combining Relations The relations converted from many-to- one and one-to-one relationships can be absorbed into the relation of the “many” side.

10 Weak Entity Set Example PlayersTeams Plays-on name numberlocation Teams( ?? ) Players( ?? ) Plays-on ??

11 Weak Entity Sets Relation for a weak entity set includes its complete key as well as it’s own non- key attributes A supporting relationship is redundant and yields no relation

12 Subclass Example Beers Ales isa name manf color

13 Subclasses Object-oriented approach One relation per class Each entity belongs to exact one relation ER approach One relation per class Each entity may appear in multiple relations NULL approach One relation per class hierarchy

14 Object-Oriented Approach namemanf BudAnheuser-Busch Beers namemanfcolor SummerbrewPete’sdark Ales

15 ER Approach namemanf BudAnheuser-Busch SummerbrewPete’s Beers namecolor Summerbrewdark Ales

16 NULL Approach namemanfcolor BudAnheuser-BuschNULL SummerbrewPete’sdark Beers

17 Discriminator nametypemanfcolor BudGeneralAnheuser-BuschNULL SummerbrewAlePete’sdark Beers Discriminator field

18 Another Subclass Example Movies titleyearlength isa Cartoons Murder- Mysteries typeweapon

19 Comparison of Subclass Conversion Approaches Constraints and data integrity Query performance Q1: find all beers made by Pete’s Q2: find colors of the ales made by Pete’s

20 Examples Receipt again Items, Customers, Waiters, and Orders Hierarchical categories Price that changes

21 Example: Survey Questions Four types of survey questions Single-choice Multiple-choice Single-answer Multiple-answer Database stores information about users, surveys, questions, and answers


Download ppt "CS422 Principles of Database Systems From ER to Relations Chengyu Sun California State University, Los Angeles Adapted from Jeffrey Ullman’s lecture notes."

Similar presentations


Ads by Google