Presentation is loading. Please wait.

Presentation is loading. Please wait.

EECS 647: Introduction to Database Systems

Similar presentations


Presentation on theme: "EECS 647: Introduction to Database Systems"— Presentation transcript:

1 EECS 647: Introduction to Database Systems
Instructor: Luke Huan Spring 2007

2 Luke Huan Univ. of Kansas
Administrative Histogram of quiz scores 9/17/2018 Luke Huan Univ. of Kansas

3 Luke Huan Univ. of Kansas
Review Relational algebra Use temporary variable Use foreign key to join relations A comparison is to identify a relationship Use minus in non-monotonic operations 9/17/2018 Luke Huan Univ. of Kansas

4 Luke Huan Univ. of Kansas
Today’s Topic Logical database design: Translation ER to relation schema 9/17/2018 Luke Huan Univ. of Kansas

5 Luke Huan Univ. of Kansas
Database Design 9/17/2018 Luke Huan Univ. of Kansas

6 Database design steps: review
Understand the mini-world Specify it using a database design model (e.g., E/R) Translate specification to the data model of DBMS (e.g., relational) Create DBMS schema Next: translating E/R design to relational schema 9/17/2018 Luke Huan Univ. of Kansas

7 Luke Huan Univ. of Kansas
E/R model: review Entity sets Keys Weak entity sets Relationship sets Attributes on relationships Multiplicity Roles Binary versus N-ary relationships Modeling N-ary relationships with weak entity sets and binary relationships 9/17/2018 Luke Huan Univ. of Kansas

8 Translating entity sets
An entity set translates directly to a table Attributes ! columns Key attributes ! Primary key Students Courses CID title Enroll SID name grade Student (SID, name) Course (CID, title) 9/17/2018 Luke Huan Univ. of Kansas

9 Translating entity sets (cont.)
Notes: No multi-valued attributes (called first Normal Form) Composite attributes is broken down into a list of atomic attributes 9/17/2018 Luke Huan Univ. of Kansas

10 Translating weak entity sets
Use a “borrowed” key Watch out for attribute name conflicts number name In Rooms Buildings capacity year In Seats number L/R? Building (building_name, year) Rooms (building_name, room_number, capacity) Seats (building_name, room_number, seat_number, left_or_right) 9/17/2018 Luke Huan Univ. of Kansas

11 Translating 1:1 Relationship
Translate a 1:1 relationship between two entities. Merging the two entity types and the relationship into a single table. Works well for total participation Students account aid date own SID name Student (SID, name, aid, date) 9/17/2018 Luke Huan Univ. of Kansas

12 Translating 1:1 Relationship (II)
Mapping 1:1 relationship using foreign key Usually choose the entity type with total participation to include the foreign key (why?) Students Bschool account Baid date own SID name Student (SID, name) Bschoool account (Baid, SID, date) 9/17/2018 Luke Huan Univ. of Kansas

13 Translating 1:1 Relationship (III)
Mapping 1:1 relationship using relation Termed as relationship relation SID Baid own Students Bschool account name date Bschoool account (Baid, date) Student (SID, name) Saccount(SID, Baid) 9/17/2018 Luke Huan Univ. of Kansas

14 Translating 1:N Relationship
Mapping 1:N relationship using foreign key Or using relationship relation EID Dnum worksfor Employee Department name Manager Employee (EID, name, Dnum) Department(Dnum, Manager) Employee (EID, name), Department(Dnum, Manager) workFor(Eid, Dnum), 9/17/2018 Luke Huan Univ. of Kansas

15 Translating M:N Relationship
Use relationship relation EID Pnum workson Employee Project name Budget Employee (EID, name), Project(Pnum, Budget) workon(Eid, Pnum), 9/17/2018 Luke Huan Univ. of Kansas

16 Mapping of Multivalued attributes.
Mapping multivalued attribute using relation. Use primary key attribute from the original entity as a foreign key in the new relation Dnum Department location Manager Department(Dnum, Manager) DepartmentLocation(Dnum, location) 9/17/2018 Luke Huan Univ. of Kansas

17 Mapping of N-ary relationship
For each n-ary (n>2) relationship type, create a new relationship relation S. Include as foreign key attributes in S the primary keys of the relations that represent the participating entity types. Supply Supplier Project Part PID Mname SID name PaID Pname Supply(SID, PID, PaID) 9/17/2018 Luke Huan Univ. of Kansas

18 Luke Huan Univ. of Kansas
More examples Persons Marry husband wife SSN Marry (husband_SSN, wife_SSN) 9/17/2018 Luke Huan Univ. of Kansas

19 Luke Huan Univ. of Kansas
Design principles KISS Keep It Simple, Stupid Avoid redundancy Redundancy wastes space, complicates updates and deletes, promotes inconsistency Capture essential constraints, but don’t introduce unnecessary restrictions Use your common sense Warning: Mechanical translation procedures given in this lecture are no substitute for your own judgment 9/17/2018 Luke Huan Univ. of Kansas

20 Luke Huan Univ. of Kansas
Review Entity Weak-entity 1:1 relationship 1:N relationship M:N relationship Atomic attribute Key attribute Composite attributes Multi-valued attributes Relation Relation, including the primary key from the parent entity as an attribute Merged relation, Foreign key, Relationship relation Foreign key, Relationship relation Relationship relation Attribute Primary key A set of attributes Relation and foreign key 9/17/2018 Luke Huan Univ. of Kansas


Download ppt "EECS 647: Introduction to Database Systems"

Similar presentations


Ads by Google