Presentation is loading. Please wait.

Presentation is loading. Please wait.

Instructor :Huda Al-Omair

Similar presentations


Presentation on theme: "Instructor :Huda Al-Omair"— Presentation transcript:

1 Instructor :Huda Al-Omair
(Chapter 3 Tutorial) Instructor :Huda Al-Omair

2 Exercise 1 Composite and multivalued attributes can be nested to any number of levels. Suppose we want to design an attribute for a STUDENT entity type to keep track of previous collage education. Such an attribute will have one entry for each college previously attended, and each such entry will be composed of college name, start and end dates, degree entries (degrees awarded at that college, if any), and transcript entries (courses completed at that college, if any). Each degree entry contains the degree name and the month and year the degree was awarded, and each transcript entry contains a course name, semester, year, and grade. Design an attribute to hold this information. Chapter 3 Tutorial 1

3 Exercise 1 (Solution) {PreviousEdication ( CollegeName, StartDate,
EndDate, {Degree (DegreeName, Month, Year)}, {Transcript (CourseName, Semester, Year, Grade)} )} Chapter 3 Tutorial 2

4 Exercise 2 Consider the ER diagram below. Assume that an employee may work in up to two departments or may not be assigned to any department. Assume that each department must have one and may have up to three phone numbers. Supply (min, max) constraints on this diagram. State clearly any additional assumptions you make. (1,M) 1. Each department can have (1-M) employee(s). (0,M) WORKS-IN EMPLOYEE DEPARTMENT 4. Each employee is assigned (1-M) phone(s). (1,M) (1,M) HAS-PHONE CONTAINS PHONE 3. Each phone is assigned to (1-M) employee(s). (1,M) 2. Each phone is used by only 1 department. (1,1) Assumptions: Chapter 3 Tutorial 3

5 Exercise 3 For each of the following pairs of rules, draw an ER diagram showing the cardinality and participation constraints: A doctor may treat many patients. A patient may have a designated doctor for different types of problems. A hospital has many patient rooms. Each patient room belongs to that hospital. An author may write many books. A book may be written by more than one author. DOCTOR PATIENT TREATS M N HOSPITAL ROOM HAS 1 N AUTHOR BOOK WRITES M N Chapter 3 Tutorial 4

6 Exercise 4 Identify the entities and relationships for the following description and draw an ER diagram. A library system contains libraries, books, authors and patrons, with identifying attributes library Number, book number, author number, and patron number, respectively. Libraries are further described by a library name and location, books by title and page count, authors by author name, and patrons by patron name and patron weight. Libraries hold numerous books (some with multiple copies), each authored by one or more authors. Patrons borrow books, but at any point in time, may not have anything checked out. When they do have a book checked out, there is a due date associated with it. Chapter 3 Tutorial 5

7 Exercise 4 (solution) LibNo LibName BookNo Title 1 HOLDS N LIBRARY
PageCount M N Location WRITTEN_BY CHECK -OUT DueDate AuthorNo N 1 AUTHOR PATRON PatronName AuthorName PatronNo PatronWeight Chapter 3 Tutorial 6

8 Exercise 5 A loan company wants to design a database to track student loans. Each student attending school is eligible for a loan. A student may have more than one loan. A student may be registered, possibly at different times, in more than one school. Each loan should belong to only one bank. Each bank can approve as many loans as it desires. For each loan, the loan company will track: the student’s SSN, name, address, amount of loan, date of loan, interest rate ( which may be different for each loan as determined by the bank), duration of loan, monthly payment, remaining balance, school ID, school name and address, number of years the student has been at the school, bank name, bank branch and bank ID. Draw an ER diagram. State any assumptions you make in the diagram. Chapter 3 Tutorial 7

9 Exercise 5 (solution) Assumption: each loan to a student (for different schools) is given a unique LoanId number. SSN SName LoanId Date Amount 1 BORROWS N STUDENT LOAN Payment Duration M SAddress N Interest ATTENTS APPROVED_BY NoOfYears Balance SchoolName N 1 SCHOOL BANK BankName SchoolId SchoolAddress BankId BankBranch Chapter 3 Tutorial 8

10 Exercise 6 (3.16) Consider the following set of requirements for a university database that is used to keep track of students’ transcripts. a. The university keeps track of each student’s name, student number, SSN, current address and phone, permanent address and phone, birth date, sex, class (freshman, sophomore,...,graduate), major department, minor department (if any), and degree program (B.A.,...).Some user applications need to refer to the city, state, and zip code of the student’s permanent address and to the student’s last name. Both SSN and student number have unique values for each student. b. Each department is described by a name, department code, office number, office phone, and college. Both name and code have unique values for each department. Chapter 3 Tutorial 9

11 Exercise 6 (3.16) c. Each course has a course name, description, course number, number of semester hours, level, and offering department. The value of the course number is unique for each course. d. Each section has an instructor, semester, year, course, and section number. The section number distinguishes sections of the same course that are taught during the same semester/year; its values are 1,2,3,..., up to the number of sections taught during each semester. e. A grade report has a student, section, letter grade, and numeric grade (0,1,2,3, or 4). Design an ER schema for this application, and draw an ER diagram for that schema. Specify key attributes of each entity type, and structural constraints on each relationship type. Note any unspecified requirements, and make appropriate assumptions to make the specification complete. Chapter 3 Tutorial 10

12 Exercise 6 (3.16) Chapter 3 Tutorial 11


Download ppt "Instructor :Huda Al-Omair"

Similar presentations


Ads by Google