Week 4

Post date: Oct 08, 2017 4:1:36 AM

/!\ Quiz 1 will be on Thursday

Chapter 7: Data Modeling Using Entity-Relationship (ER) Model

    • High-level conceptual data models

    • Entity types, entity sets, attributes, and keys

    • Relationship types, relationship sets, roles, and structural constraints

    • Weak entity type

    • ER diagrams, naming conventions, and design issues

In-Class Exercises:

Ex 1:

Write the requirement specifications that led to the following ER diagram:

Example of a solution:

  • A car insurance company wants to design a database to record all car accidents.

  • The information of every person (identified by the the driver number, address, and name) who owns a car (identified by license plate, model and year) is stored in the system.

  • When an accident occurs, the company needs to record the report number, the location, and the date of the accident.

  • When a person is involved in an accident with a car, the amount of the damage has to be recorded, regardless if the driver is the owner of the car or not.

Ex 2:

Construct an E-R diagram for a hospital with a set of patients recording their social security number, the date admitted and the date they checked-out of the hospital, and a set of medical doctors, using their names and specializations. Associate with each patient a log of the various tests and examinations conducted.

Example of a solution:

Assumptions:

    1. Every test has an id and name

    2. Every doctor has a ss#

    3. Only 1 doctor performs a test

    4. A test might not be done by any patient

Ex 3:

Consider the following set of requirements for a UNIVERSITY database that is used to keep track of students' transcripts. This is similar but not identical to the database shown in Figure 1.2:

(a) The university keeps track of each student's name, student number, social security number, current address and phone, permanent address and phone, birthdate, sex, class (freshman, sophomore, ..., graduate), major department, minor department (if any), and degree program (B.A., B.S., ..., Ph.D.). Some user applications need to refer to the city, state, and zip of the student's permanent address, and to the student's last name. Both social security number 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.

(c) Each course has a course name, description, course number, number of semester hours, level, and offering department. The value of course number is unique for each course.

(d) Each section has an instructor, semester, year, course, and section number. The section number distinguishes different 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, 4 for F, D, C, B, A, respectively).

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.

Example of a solution:

Ex 4:

You are asked to set up a database called "ArtBase" that builds a product for art galleries. The core of this product is a database with a schema that captures all the information that galleries need to maintain.

Galleries keep information about artists, their names (which are unique), birthplaces, age,and style of art. For each piece of artwork, the artist, the year it was made, its unique title, its type of art (e.g., painting, lithograph, sculpture, photograph), and its price must be stored. Pieces of artwork are also classified into groups of various kinds, for example, portraits, still lifes, works by Picasso, or works of the 19th century; a given piece may belong to more than one group.

Each group is identified by a name (like those just given) that describes the group. Finally, galleries keep information about customers. For each customer, galleries keep that person’s unique name, address, total amount of dollars spent in the gallery (very important!), and the artists and groups of art that the customer tends to like.

Draw the ER diagram for the database.

Example of a solution:

Assumption: Each art work can only be created by one artist