0% found this document useful (0 votes)
1K views8 pages

Part A Entity Relationship Modeling

The document describes several database design scenarios involving entities such as students, universities, DVD rentals, parking lots, and libraries. It provides descriptions of the different entities and relationships involved in each scenario and asks questions about identifying the entities, relationships, attributes, keys, and drawing ER diagrams to model the data. It also provides SQL queries and relational algebra questions related to schemas involving flights, employees, books, and borrowers.

Uploaded by

haha huhu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1K views8 pages

Part A Entity Relationship Modeling

The document describes several database design scenarios involving entities such as students, universities, DVD rentals, parking lots, and libraries. It provides descriptions of the different entities and relationships involved in each scenario and asks questions about identifying the entities, relationships, attributes, keys, and drawing ER diagrams to model the data. It also provides SQL queries and relational algebra questions related to schemas involving flights, employees, books, and borrowers.

Uploaded by

haha huhu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

PART A – ENTITY RELATIONSHIP MODELING

1. Assume you have been contracted by a university to develop a database system to keep track of student
registration and accommodation records. The university courses are offered by faculties. Depending
on the student’s IQ, there are no limitations to how many courses a student can enroll in. The faculties
are not responsible for student accommodation. The university owns a number of hostels and each
student is given a shared room key after enrollment. Each room has furniture attached to it.

a) Identify the main entity types for the project.

b) Identify the main relationship types and specify the multiplicity for each relationship. State any
assumptions that you make about the data.

c) Using your answers for (a) and (b), draw a single ER diagram to represent the data

2. Read the following case study, which describes the data requirements for a DVD rental company. The
DVD rental company has several branches throughout the USA. The data held on each branch is the
branch address made up of street, city, state, and zip code, and the telephone number. Each branch is
given a branch number, which is unique throughout the company. Each branch is allocated staff,
which includes a Manager. The Manager is responsible for the day-to-day running of a given branch.
The data held on a member of staff is his or her name, position, and salary. Each member of staff is
given a staff number, which is unique throughout the company. Each branch has a stock of DVDs. The
data held on a DVD is the catalog number, DVD number, title, category, daily rental, cost, status, and
the names of the main actors, and the director. The catalog number uniquely identifies each DVD.
However, in most cases, there are several copies of each DVD at a branch, and the individual copies
are identified using the DVD number. A DVD is given a category such as Action, Adult, Children,
Drama, Horror, or Sci-Fi. The status indicates whether a specific copy of a DVD is available for rent.
Before hiring a DVD from the company, a customer must first register as a member of a local branch.
The data held on a member is the first and last name, address, and the date that the member registered
at a branch. Each member is given a member number, which is unique throughout all branches of the
company. Once registered, a member is free to rent DVDs, up to maximum of ten at any one time.
The data held on each DVD rented is the rental number, the full name and number of the member, the
DVD number, title, and daily rental, and the dates the DVD is rented out and date returned. The
rental number is unique throughout the company.

(a) Identify the main entity types of the DVD rental company.
(b) Identify the main relationship types between the entity types described in (a) and
represent each relationship as an ER diagram.
(c) Determine the multiplicity constraints for each relationship described in (b). Represent
the multiplicity for each relationship in the ER diagrams created in (b).
(d) Identify attributes and associate them with entity or relationship types. Represent each
attribute in the ER diagrams created in (c).
(e) Determine candidate and primary key attributes for each (strong) entity type.
(f) Using your answers (a) to (e) attempt to represent the data requirements of the DVD
rental company as a single ER diagram. State any assumptions necessary to support your
design.
3. Create an ER model for each of the following descriptions:

(a) A large organization has several parking lots, which are used by staff.

(b) Each parking lot has a unique name, location, capacity, and number of floors (where
appropriate).

(c) Each parking lot has parking spaces, which are uniquely identified using a space number.

(d) Members of staff can request the sole use of a single parking space. Each member of staff has
a unique number, name,telephone extension number, and vehicle license number.

(e) Represent all the ER models described in parts (a), (b), (c), and (d) as a single ER model.
Provide any assumptions necessary to support your model.

4. Create an ER model to represent the data use by the library.

The library provides books to borrowers. Each book is described by title, edition and year of
publication and is uniquely identified using the ISBN. Each borrower is described by his or her name
and address and is uniquely identified using a borrower number. The library provides one or more
copies of each book and each copy is uniquely identified using a copy number, status indicating if the
book is available for loan and the allowable loan period for a given copy. A borrower may loan one or
many books and the date each book is loaned out and is returned is recorded. Loan number uniquely
identifies each book loan.
ANSWER

Video

catalogNo

1..1

Is

1..*
Has
VideoForRent IsAllocated Branch Staff
1..1 1..*
Manages
videoNo 1..* 1..1 branchNo staffNo
0..1 1..1
1..1 1..1

Registers

IsPartOf 1..* Registration

1..* 1..*

Agrees

1..1

0..* RentalAgreement Member


Requests
rentalNo 0..* 1..1 memberNo
PART B – SQL CODES

1. The following relations keep track of airline flight information

Flights (flno, from, distance, depart, time, arrives, time, price)


Aircraft (aid , aname , cruisingrange )
Certified (eid , aid )
Employees (eid , ename , salary )

Note that the Employees relation describes pilots and other kinds of employees as well; every pilot is
certified for some aircraft, and only pilots are certified to fly. Write each of the following queries in SQL.

a) Find the names of aircraft such that all pilots certified to operate them have Salaries more than
$80,000.
(5 marks)
b) For each pilot who is certified for more than three aircraft, find the eid and the maximum cruising
range of the aircraft for which she or he is certified.
(2 marks)

c) Find the names of pilots whose salary is less than the price of the cheapest route from Los
Angeles to Honolulu.
(2.5 marks)
d) For all aircraft with cruising range over 1000 miles, find the name of the aircraft and the average
salary of all pilots certified for this aircraft.
(2.5 marks)
e) Find the names of pilots certified for some Boeing aircraft.
(1.5 marks)

f) Find the aids of all aircraft that can be used on routes from Los Angeles to Chicago.
(2 marks)

g) Compute the difference between the average salary of a pilot and the average salary of all
employees (including pilots).
(3 marks)

h) Print the name and salary of every nonpilot whose salary is more than the average salary for
pilots.
(4 marks)

i) Print the names of employees who are certified only on aircrafts with a cruising range longer than
1000 miles.
(2.5 marks)
2. The following tables form part of a Library database held in an RDBMS:

Book (ISBN, title, edition, year)


BookCopy (copyNo, ISBN, available)
Borrower (borrowerNo, borrowerName, borrowerAddress)
BookLoan (copyNo, dateOut, dateDue, borrowerNo)

Formulate the additional queries in relational algebra

i) List all book titles.


(1 mark)

ii) List all book titles published in the year 2012.


(2 marks

iii)List all copies of book titles that are available for borrowing.
(3 marks)

iv) List all copies of the book title “Lord of the Rings” that are available for borrowing.
(4 marks)

v) List the names of borrowers who currently have the book title “Lord of the Rings” on loan.
(5 marks)

vi) Produce a report of book titles that have been borrowed by “Peter Bloomfield”.
(5 marks)
PART C – NORMALIZATION

1. A local family has a large garden and regularly sells produce at the local Farmer’s Market. Up to
now the group has just picked items and sold them each week—basically tracking just the amount
of money received. Now the family wants to track sales by types of items (potatoes, lettuce,
tomatoes, carrots, and so on); both in terms of quantity sold and the amount of money received.
They want to use the data to determine planting amounts for the coming year. The crops require
about the same level of fertilizer and watering so profits are mainly determined by the yield and
the price received. No one wants to create individual item receipts for each sale—that would take
too much time, but they will use a tally sheet to record the number of items sold and the prices.
Then enter the sales into a computer (or tablet) at the end of the day. Some items are sold by the
unit (such as melons or lettuce--bunch) while others, such as carrots, are sold by the pound. The
family starts out the day with a set price, but if items are not selling well and have a limited shelf
life, the price is reduced. So the amount sold needs to be recorded at each price point.
Convert each of the following schemas to 3NF, showing all intermediate stages, that is, 1NF and 2NF.

1. BRANCH (Branch#, Branch_Addr, (ISBN, Title, Author, Publisher, Num_copies))

1NF:
BRANCH-1 (Branch#, Branch_Addr)
STOCKS-1 (Branch#, ISBN, Title, Author, Publisher, Num_copies)
 2NF:

BRANCH-2(Branch#, Branch_Addr) or OK
STOCKS-2 (Branch#, ISBN, Num_copies)
BOOK-2 (ISBN, Title, Author, Publisher)
 3NF:

BRANCH-3(Branch#, Branch_Addr) or OK
STOCK-3 (Branch#, ISBN, Num_copies) or OK
BOOK-3 (ISBN, Title, Author, Publisher) or OK

You might also like