EER Model 2
EER Model 2
EER Model 2
Question 1
iv. Keys. What is the difference between a candidate key, a primary key and a
composite key? What considerations might influence the choice of a
primary key?
A library service wants to create a database to store details of its libraries, books
and borrowers. Details include the following:
A book has a unique ISBN number, a title and one or more authors. The
library service may own several copies of a given book, each of which is
located in one of the service’s libraries. A given library contains many books,
and in order to distinguish different copies of the same book a library assigns a
different copy-number to each of its copies of a given book; the price that was
paid for each copy is also recorded. Every library has a unique name and is
either a main library or a branch library. A main library may have zero or more
branch libraries and every branch library is a branch of exactly one main
library. A borrower has a name and a unique ID code. A borrower can have
many books on loan, but each copy of a book can only be on loan to one
borrower. A borrower could borrow the same book on several occasions, but it
is assumed that each such loan will take place on a different date.
title author
ISBN Book
m
m m m 1
Borrower borrow Loan lend Copy
m
1
Library
Main Branch
1 m
branch
Figure 2
Figure 2 illustrates a preliminary design of an Extended-Entity-Relationship
model intended to meet the above specification. The design contains at least
10 errors. Describe each error, clearly stating both the nature of the problem
and its solution, and draw a corrected EER model.
title author
ISBN Book
m
1 m m 1
Borrower borrow Loan lend Copy
m
1
Library
no-of-branches d
Main Branch
1 m
branch
Figure 2
Question 3
description part-num
name
city
ID name contains
m
Customer 1 m Order
order
order-num
Figure 3
Map the EER model into a relational schema, clearly indicating all primary
and foreign keys (also stating into which relations they are keys).
A record company wishes to use a computer database to help with its operations
regarding its performers, recordings and song catalogue. A requirements analysis has
elicited the following information:
• Songs have a unique song number, a non-unique title and a composition date.
A song can be written by a number of composers; the composer’s full name is
required. Songs are recorded by recording artists (bands or solo performers). A
song is recorded as a track of a CD. A CD has many songs on it, called tracks.
CDs have a unique record catalogue number, a title and must have a producer
(the full name of the producer is required). Each track must have the recording
date and the track number of the CD.
• A song can appear on many (or no) CDs, and be recorded by many different
recording artists. The same recording artist might re-record the same song on
different CDs. A CD must have only 1 recording artist appearing on it. CDs
can be released a number of times, and each time the release date and
associated number of sales is required.
There are many possible “correct” answers to this question (I have seen at least
six, plus innumerable minor variations) – remember that EER modeling is not
an exact science. If in doubt about your own design, ask one of us about it in an
examples class.