Presentation is loading. Please wait.

Presentation is loading. Please wait.

E/R Exercises – Part I April 16, 2017.

Similar presentations


Presentation on theme: "E/R Exercises – Part I April 16, 2017."— Presentation transcript:

1 E/R Exercises – Part I April 16, 2017

2 Database Design Sequence

3 Review Entity set Weak entity set Relationship set
Weak relationship set Attribute Multiplicity of relationships Referential integrity

4 Different Sets of Notations
Two different sets of ER notations are commonly used. One from Ullman’s book as shown on the last slide Another from Ramakrishnan’s book with main differences in: - arrow always pointing to “relationship”; - notations of partial or total participation constrains; - notation of aggregations.

5 Exercise #1 - 1 A database for a bank includes information about customers and their accounts. Information about customer includes name, address, phone, and social security number. Accounts have numbers, type (saving, checking), and balances. An account can be owned by several customers, and a customer can have multiple accounts.

6 Exercise #1 - 2 number type balance Customer Account SSN name address
phone own

7 Exercise #2 Change your design so that an account can have exactly one customer number type balance Account own Customer SSN name address phone

8 Exercise #3 Further change your design so a customer can have at most one account number type balance Customer SSN name address phone Account own

9 Exercise #4 - 1 Change your original design so that a customer can have a set of addresses (street, city, state) and a set of phones. Remember that we do not allow non-atomic types for attributes.

10 Exercise #4 - 2 street city Address Phone number state number type
Lives at has number type balance name Customer own Account SSN

11 Exercise #5 - 1 Further change your original design so that a customer can have a set of addresses. Also, at each address, there is a set of phones.

12 Exercise #5 - 2 street city Address Phone number has state name number
Lives at name number type balance Customer own Account SSN

13 Exercise #6 - 1 Design a database for a university registrar.
This database should include information about students, departments, professors, courses, which student are enrolled in which courses, which professors teach which courses, student grades, TA for the course (TAs are students), which courses a department offers, and any other information you deem appropriate.

14 Exercise #6 – Solution #1 position EID semester section section
tutor of teaches Professor hired semester TA grade semester section Student enroll Course offer Department number name credit name name address phone id Is this a good design? OK, but not a good design. “semester” and “section” appear in several relationships -> Can’t guarantee the consistency of DB easily

15 Exercise #6 – Solution #2 position EID Professor TA section semester
hired TA section semester Student isIn Course offer Department grade number name credit name name address phone id Is this a good design? No. Lots of redundancy (in “isIn”), although the E/R diagram itself looks simpler

16 Exercise #6 – Solution #3 position EID Professor TA grade section
tutor of teaches Professor hired TA grade section semester Student enroll Course offer Department number name credit name name address phone id This solution has less redundancy comparing to the previous 2. But redundancy still exists in “Course”. Is this a good design?

17 Exercise #6 – Solution #4 position EID Professor semester TA Available
tutor of teaches Professor hired semester TA Available Course section Student enroll Course offer Department grade number name credit name name address phone id Is this a good design? Yes!


Download ppt "E/R Exercises – Part I April 16, 2017."

Similar presentations


Ads by Google