Você está na página 1de 10

Part 1

1. What kind of data model is the relational model?

2. (a) Explain the following terms in the context of the relational data model.

Relation
Attribute
Domain
Tuple
Degree
Cardinality

(b) Use the Suppliers–Parts database to provide examples of each (see Appendix 1 of
this tutorial).

3. (a) Explain the following terms in the context of the relational data model.

Candidate Key
Primary Key
Foreign Key

(b) Use the Suppliers–Parts database to provide examples of each.

4. (a) What is the purpose of nulls and what do they represent?


(b) Is a component of a primary key allowed to accept nulls, why?
(c) What is the term for this constraint?
(d) Use the Suppliers–Parts database to discuss why it is desirable to enforce this
constraint.

5. (a) Describe the constraint called referential integrity.


(b) What is the purpose of this constraint?
(c) Use the Suppliers–Parts database to discuss why it is desirable to enforce
referential integrity.

6. Examine your ‘course timetable’ and try to answer the following questions:

(a) Have all data in the timetable interpretations?


(b) Are the data and their interpretations kept together?
(c) Is there any data model behind the data? If so what kind of data model is it and why?
(d) Are the data structured in a relation and why?
(e) How would you re-structure the data according to the rules of the relational data
model?

7. (a) What is a view?


(b) Discuss the difference between a view and a base relation.
(c) Explain what happens when a user accesses a database through a view.

Part 2

1. What are the two major components of SQL and what function do they serve?

2. What are the advantages and disadvantages of SQL?

3. The following tables form part of a database held in a relational DBMS.

Hotel (hotelNo, name, address)


Room (roomNo, hotelNo, type, price)
Booking (hotelNo, guestNo, dateFrom, dateTo, roomNo)
Guest (guestNo, name, address)

where

Hotel contains hotel details and hotelNo is the primary key.


Room contains room details for each hotel and roomNo, hotelNo forms the primary key.
Booking contains details of the bookings and the primary key comprises hHotelNo, guestNo
and dateFrom.
Guest contains guest details and guestNo is the primary key.

(a) Construct an SQL statement to answer the following queries.

(i) List full details of all hotels.

(ii) List full details of all hotels in London.

(iii) List the names and addresses of all guests in London, alphabetically ordered
by name.

(iv) List all double or family rooms with a price below £40.00 per night, in
ascending order of price.

(v) List the bookings for which no date_to has been specified.

(vi) How many hotels are there?


(vii) What is the average price of a room?

(viii) What is the total revenue per night from all double rooms?
(ix) List the price and type of all rooms at the Grosvenor Hotel.

(x) List all guests currently staying at the Grosvenor Hotel.

(xi) What is the total income from bookings for the Grosvenor Hotel today?

(xii) List the number of rooms in each hotel.

(xiii) List the number of rooms in each hotel with more than 100 rooms and
located in London.

(xiv) What is the most commonly booked room type for each hotel in London?

Part 3

1. Given the following descriptions, create an appropriate ER diagram for each of the
specified relationships.

(a) Each company operates four departments, and each department belongs to one
company.
(b) Each department in part (a) employs one or more employees, and each employee is
employed by one department.
(c) Each of the employees in part (b) may or may not have one or more dependants, and
each dependant belongs to one employee.
(d) Each employee in part (c) may or may not have an employment history.

2. Represent all of the relationships described in Question 1 as a single ER diagram.

3. Create an ER diagram to represent the tables of the StayHome video rental shop (as described
in the Access 2000 manual).

4. The IT Training Group (Glasgow) has contacted you to create a conceptual model by using
the Entity–Relationship data model for a database that will meet the information needs for
its training program. The Company Director gives you the following description of the
training group’s operating environment.

The Company has twelve instructors and can handle up to one hundred trainees per
training session. The Company offers five advanced technology courses, each of which is
taught by a teaching team of two or more instructors. Each instructor is assigned to a
maximum of two teaching teams or may be assigned to do research. Each trainee
undertakes one advanced technology course per training session.
Given this information, draw an ER diagram for IT Training Group (Glasgow).

5. Suppose you are involved in developing a database system for the Sales Department of a
company. The operation of the Department can be described as follows:

They have a file of products that they provide to their customers. Each type of product
has a unique product number, as well as a description, a cost and a price. The number of
the product in stock and the number allocated are updated regularly. When the number in
stock decreases to the reorder level, the product is reordered in a pre-decided quantity.

They have a file of customers. Each customer is given a unique customer number. This
file also contains customer names that consist of their first and last names, and customer
addresses composed of street, city and postcode and the customer telephone number.
Each customer has a credit limit, which is used to validate their orders.

A customer may place zero, one or more orders at a time, and an order is always placed
by one customer alone. Each order is identified by a unique order number. Other
information as to orders includes the date due, the total price, and the status, that is, an
order may be outstanding, partially delivered, or fully delivered and invoiced.

An order may involve one or more than one type of products, and a type of products may
be involved in more than one order. For each product being ordered in an order, its
quantity, total price, and status (i.e., outstanding, partially delivered, or fully delivered)
are recorded and updated regularly.

Given this information, draw an ER diagram for this Sales Department.

Part 4

1. Examine the table shown below.

branchNo branchAddress telNos


B001 8 Jefferson Way, Portland, OR 97201 503-555-3618, 503-555-2727, 503-555-6534

B002 City Center Plaza, Seattle, WA 98122 206-555-6756, 206-555-8836

B003 14 – 8th Avenue, New York, NY 10012 212-371-3000

B004 16 – 14th Avenue, Seattle, WA 98128 206-555-3131, 206-555-4112

(a) Why is this table not in 1NF?


(b) Describe and illustrate the process of normalizing the data shown in this table to third
normal form (3NF).
(c) Identify the primary, alternate and foreign keys in your 3NF relations.

2. Examine the table shown below.


staffNo branchNo branchAddress name position hoursPerWeek

S4555 B002 City Center Plaza, Seattle, WA 98122 Ellen Layman Assistant 16

S4555 B004 16 – 14th Avenue, Seattle, WA 98128 Ellen Layman Assistant 9

S4612 B002 City Center Plaza, Seattle, WA 98122 Dave Sinclair Assistant 14

S4612 B004 16 – 14th Avenue, Seattle, WA 98128 Dave Sinclair Assistant 10

(a) Why is this table not in 2NF?


(b) Describe and illustrate the process of normalizing the data shown in this table to third
normal form (3NF).
(c) Identify the primary, (alternate) and foreign keys in your 3NF relations.
3. Examine the table shown below.

branchNo branchAddress telNo mgrStaffNo name

B001 8 Jefferson Way, Portland, OR 97201 503-555-3618 S1500 Tom Daniels

B002 City Center Plaza, Seattle, WA 98122 206-555-6756 S0010 Mary Martinez

B003 14 – 8th Avenue, New York, NY 10012 212-371-3000 S0145 Art Peters

B004 16 – 14th Avenue, Seattle, WA 98128 206-555-3131 S2250 Sally Stern

(a) Why is this table not in 3NF?


(b) Describe and illustrate the process of normalizing the data shown in this table to third normal
form (3NF).
(c) Identify the primary, (alternate) and foreign keys in your 3NF relations.

4. The purpose of this form shown below is to record the medication given to a particular
patient at the Wellmeadows Hospital. Examine the data shown on the form. Discuss how the
data shown on this form could be represented in tables.

Wellmeadows Hospital
Patient Medication Form

Patient Number : P10034

Full Name : Robert MacDonald Ward Number : Ward 11

Bed Number : 84 Ward Name : Orthopaedic

Drug Method Units per Start Finish


Name Description Dosage of
Number Day Date Date
Admin

10223 Morphine Pain Killer 10mg/ml 24/04/96


Oral 50 24/03/96

10334 Tetracyclene Antibiotic 0.5mg/ml IV 17/04/96


10 24/03/96

10223 Morphine Pain Killer 10mg/ml 02/05/96


Oral 10 25/04/96

Part 5

1. Represent the entity and relationship types shown in the ER diagrams below as relations.
Employment
Employee
Holds Contract
empNo {PK} 1..1 1..1
name contractNo {PK}
address position
date
salary

Employee Project
WorksOn
empNo {PK} 1..* 1..* projectNo {PK}
name pName
address description

hours

Vehicle Has Check

regNo {PK} 1..1 0..* date {PPK}


make faults
model

sDate
0..*
Supervises
Employee

empNo {PK} 0..1


name
address
2. The ER diagrams shown below are taken from the example answers for Question 2
and 5 of the Chapter 11 Entity–Relationship Modeling Tutorial. However, for the purposes
of this tutorial, the attributes associated with entity or relationship types are also included in
the diagrams. Present a relational schema for each of the ER diagrams shown below.

(a)

Company Department
Operates
cName {PK} dNo {PK}
cAddress 1..1 1..*
dName
cTelNo dLoc
cFaxNo
1..1

Employs

1..*

Employment Employee
History Has
empNo {PK}
0..* 1..1 name
compOrganName fName
(PPK} lName
address address
position
sDate 1..1
fDate

RelatedTo

0..*

Dependent
dName {PPK}
dAddress
relationship
(b)

OrderDetails Product
Requires
qty prodNo {PK}
status 1..* 1..1
desc
/totalPrice price
cost
1..*
numberAllocation
reorderQty
reorderLevel
PartOf inStock

1..1

Order Customer
Places
custNo {PK}
ordeNo (PK} 1..* 1..1 name
status fName
dateDue lName
/totalPrice address
street
city
postcode
telNo
creditLimit
3. Present a relational schema for the ER diagram shown below.

0..*
Supervises WorksFor

Employee 1..* 1..1 Department

0..1 SSN {PK} name {PK}


name number
fName Manages locations [1…5]
mI /noOfEmployees
lName 1..1 0..1
address 1..1
sex startDate
salary
bDate

1..1 Controls
1..*

RelatedTo
WorksOn

hours
0..* 0..*
0..*

Dependent Project

dName {PPK} number {PK}


relationship name {AK}
sex location
birthDate

Você também pode gostar