1 of 6
founder
organization
since
join
name
leader
country 1
capital
1
name
of
area
continent 1
1
city
on
*
part 1
name
name
population
in
direction
Solution
continent (name, area);
organization (name, founder);
country (name, leader, capital)
FK(capital) to city;
orgMember (orgName, countryName, since)
FK(orgName) to organization,
FK(countryName) to country;
part (countryName, partName, direction, continentName)
FK(countryName) to country,
FK(continentName) to continent;
city (name, population, countryName, partName)
FK(countryName, partName) to part;
Kriengkrai Porkaew
porkaew@it.kmutt.ac.th
MSc(IT), KMUTT
2 of 6
rating
ID
name
description
name
rate
title
actor
in
type
description
category
of
address
customer 1
director
rent
date
number
*
copy
media
Solution
customer (ID, name, address);
rating (code, ratingDescription);
category (type, categoryDescription);
title (name, director, ratingCode)
FK(ratingCode) to rating;
actor (actorName, titleName)
FK(titleName) to title;
titleCategory (titleName, categoryType)
FK(titleName) to title,
FK(categoryName) to category;
copy (titleName, copyNumber, media, rentDate, renter)
FK(titleName) to title,
FK(renter) to customer;
Kriengkrai Porkaew
porkaew@it.kmutt.ac.th
MSc(IT), KMUTT
3 of 6
3. Construct an E-R diagram from the following set of tables. State all reasonable
assumption that you make.
instructor (IID, iName, office);
student (SID, sName, advisor, degree)
FK (advisor) to instructor;
course (code, title);
prerequisite (code, prerequisiteCode);
FK (code) to course and FK (preCode) to course;
classroom (number, floor, building);
lecture (code, semester, lecturer, roomNo, time);
FK (code) to course, FK (lecturer) to instructor, and FK (roomNo) to classroom;
registration (SID, code, semester, grade)
FK (SID) to student and FK (code, semester) to lecturer;
Solution
Using ER Notation:
number
code
title
floor
course
prerequisite
building
classroom
at
offer
name
lecture
IID
semester
time
office
instructor
teach
grade
take
SID
student
advise
name
degree
classroom
number
floor
1
building
instructor
IID
name
office
offer
at
teach
1
*
advise
Kriengkrai Porkaew
porkaew@it.kmutt.ac.th
*
*prerequisite of
*
lecture
semester
time
take
*
student
SID
name
degree
June 17, 2002
registration
grade
MSc(IT), KMUTT
4 of 6
4. Suppose that we have the following requirements for a university database that is use
to keep track of students transcripts:
The university keeps track of each students name; student number; address and
phone; major department; minor department (if any); and degree program (i.e.,
B.A., B.S., , or Ph.D.). Student number is unique for each student.
Each department is described by name, department code, office number, office
phone. Department code is unique for each department.
Each course has a course name, description, course number, number of semester
hours (credit), and offering department. The course number is unique for each
course.
Each section has an instructor name, semester, year, course number, and section
number. The section number distinguishes different sections of the same course
that are taught during the same semester and year; its values are 1, 2, 3, , up to
the total number of the sections taught during each semester.
A grade record refers to each student, a particular section, and a grade.
Construct an ER diagram corresponding to the above requirement and convert it to a
set of tables, each of which is associated with a primary key and foreign keys (when
applicable).
Solution
Using ER Notation:
name
code
office
phone
department
number
minor
degree
student
major
offer
*
course
number
name
description
credit
1
of
major
minor
instructor
section
of
name
year
semester
secNo
credit
course
offer
SID
department 1
code
name
1
office
phone
1
description
name
grade
record
section
sectionNo
semester
year
instructor
*
take
*
*
student
SID
*
name
degree
record
grade
MSc(IT), KMUTT
5 of 6
5. A department store records data of its employees, departments, and products it sells.
Each employee has a unique id, a name, an address, a phone number, and the
department he/she works for. Each employee works for one department only. Each
department has a unique name, a phone number, and a manager, who is an
employee. Each product has a unique product code, a name, a product type, and its
price. Each product type is sold by one department only. Design a conceptual
schema for this requirement and convert it to a set of tables, each of which is
associated with a primary key and foreign keys (when applicable).
Solution
Using ER Notation:
name
address
ID
work for
employee
phone
name
phone
manage
department
name
code
sell
type
product type
of
price
product
*
1
department
product type
1
*
1
type
name
*
of
phone
sell
*
manage
product
code
name
price
Kriengkrai Porkaew
porkaew@it.kmutt.ac.th
MSc(IT), KMUTT
6 of 6
overlapping
EMPLOYEE
STUDENT
complete
subtype
d
UNDERGRAD
GRAD
disjoint
STAFF
LECTURER
Kriengkrai Porkaew
porkaew@it.kmutt.ac.th
GRAD
EMPLOYEE
{disjoint}
STAFF
LECTURER
MSc(IT), KMUTT