IS222 Semester 1, 2012
IS222 Semester 1, 2012
Serving the Cook Islands, Fiji, Kiribati, Marshall Islands, Nauru, Niue, Samoa, Solomon Islands, Tokelau, Tonga, Tuvalu, and Vanuatu.
3. Dependencies based on only a part of a composite primary key are called ____
dependencies.
a. primary
b. partial
c. incomplete
d. composite
7. In a relationship, when a primary key from one table is also defined in a second
table, the field is referred to as a ____ in the second table.
a. combined key
b. redundant field
c. primary key
d. foreign key
Page 2 of 12
8. Which of the following statements concerning the primary key is true?
a. The primary key must not be null.
b. The primary key may be null.
c. The primary key is not required for all tables.
d. The primary key data do not have to be unique.
11. A ____ entity has a primary key that is partially derived from the parent entity in the
relationship.
a. strong
b. weak
c. business
d. relationship
13. ANSI-standard SQL allows the use of special operators in conjunction with the
WHERE clause. A special operator used to check whether an attribute value
matches a value contained within a subset of listed values is ____.
a. BETWEEN
b. IS NULL
c. LIKE
d. IN
14. What operator could be used in place of MINUS if the RDBMS does not support it?
a. IN
b. NOT IN
c. AND
d. UNION
Page 3 of 12
15. When using an equality (=) or inequality (<, >, etc.) operator for a subquery, what
type of value must the subquery return?
a. single value
b. list of values
c. no value
d. virtual table
20. All transactions are controlled and executed by the ____ to guarantee database
integrity.
a. scheduler
b. DBMS
c. transaction log
d. DBA
Page 4 of 12
Section B – Short and Long Answer Questions
Use the following description to answer parts (A) to (D) of this question.
The data given below is a sample employee timesheet for employees of ABC
Construction Company. The company constructs buildings. It has a number of
departments: Finance, Electrical, Plumbing and Carpentry. Each department has many
employees but each employee works for exactly one department.
All employees of the Electrical, Plumbing and Carpentry departments are required to
submit a timesheet showing the jobs they have done at the end of each week. A sample
timesheet for employee Smith Thomas, who works for the Electrical department, is given
in Figure 1.
An employee can be involved in many jobs and each job can contain one or many
operations. Each job has a unique number, description, and a manager. Each operation
has a unique ID number, description and hourly charge. An operation can be performed
by at least one employee but each employee specialises in exactly one job.
We would like to design a MS Access database to be able to store the timesheets of all
employees in the three departments (Electrical, Plumbing and Carpentry). This database
will then be used by the Finance department to make the pay of the employees in these
three departments.
Page 5 of 12
(A) What are some techniques the database designer can apply to identify the business
rules? (2 marks)
(B) Identify all possible business rules for the above case study. (8 marks)
(C) Create an ERD showing a possible database design. Show the entities, relationship
between the entities (show the connectivity, cardinality, and strength of relationship),
primary and foreign keys, and other attributes. (22 marks)
ii. Choose any one attribute that should be indexed apart from the primary and
foreign keys, and briefly justify your choice. (1 mark)
Page 6 of 12
Question 22 – Normalization (18 marks)
Use the following description and the three tables to answer parts (A) and (B) of this
question.
A transport company provides a number of trucks for cartage purposes. These trucks are
hired by people for a number of different reasons, for example, for carting household
items when moving from one house to another.
The trucks operate from a base, which is managed by at least one employee of the
company. A truck may operate from one or multiple bases over a period of time. A base
will have at least one truck at any given time.
The company hired a database designer to create a MS Access database that could be
used by the company to store details about the trucks. The implemented MS Access
database contains three tables, which are provided together with the relational schema in
Figure 2.
Base
Base City State Area Code Phone Manager
501 Murfreesboro TN 615 123-4567 or 123-4577 Andrea D. Gallager
502 Lexington KY 568 234-5678 or 234-5699 Andrea D. Gallager
and
Maria J. Talindo
503 Cape Girardeau MO 456 345-6789 Maria J. Talindo
504 Dalton GA 901 456-7890 Peter F. McAvee
Truck
Truck # Base Base City Base Phone Truck Miles Serial Num
Type
1001 501 Murfreesboro 123-4567 or 123- 1 32123.5 AA-322-12212-W11
4577
1002 501 Murfreesboro 123-4567 or 123- 1 76984.3 AC-342-22134-Q23
4577
1002 502 Lexington 234-5678 or 234- 1 76984.3 AC-342-22134-Q23
5699
1003 501 Murfreesboro 123-4567 or 123- 2 12346.6 AC-445-78656-Z99
4577
1003 503 Cape Girardeau 345-6789 2 12346.6 AC-445-78656-Z99
1005 503 Cape Girardeau 345-6789 2 45673.1 FR-998-32245-W12
1006 501 Murfreesboro 123-4567 or 123- 2 93245.7 AD-456-00845-R45
4577
1006 503 Cape Girardeau 345-6789 2 93245.7 AD-456-00845-R45
Page 7 of 12
Truck Type
Type Description
1 Single box, double-axle
2 Single box, single-axle
3 Tandem trailer, single-axle
Figure 2
(A) Discuss some problems with the design of above database and provide examples of
the problems that you have identified. (4 marks).
(B) The current database has three tables. Redesign, that is normalize, the database so that
all the tables are in 3NF and create the dependency diagrams for all the tables in your
re-designed database. Use the primary keys identified in the relational schema for the
normalization process. (14 marks)
Page 8 of 12
Question 23 – Transaction Management (11 marks)
(B) Suppose you are a manufacturer of product ABC, which is composed of parts A, B,
and C. Each time a new product (ABC) is created, it must be added to the product
inventory, using the PROD_QOH in a table named PRODUCT. This means that we
will update the PRODUCT table by increasing the PROD_QOH by 1 (one) to
indicate that we have one more of product ABC in our stock/inventory. And each
time the product ABC is created, the parts inventory, using PART_QOH in a table
named PART, must be reduced by one each of parts A, B, and C to indicate that we
have used 1 each of A, B, and C to make product ABC. The sample database
contents are shown in Figure 3.
Table name: PRODUCT Table name: PART
PROD_CODE PROD_QOH PART_CODE PART_QOH
ABC 23 A 56
B 12
C 45
Figure 3
Using the following transaction (in Figure 4), write the transaction log using the table
given in Figure 5 as your template.
SQL statements
BEGIN TRANSACTION
UPDATE PRODUCT
SET PROD_QOH = PROD_OQH + 1
WHERE PROD_CODE = ‘ABC’
UPDATE PART
SET PART_QOH = PART_OQH - 1
WHERE PART_CODE = ‘A’
UPDATE PART
SET PART_QOH = PART_OQH - 1
WHERE PART_CODE = ‘B’
UPDATE PART
SET PART_QOH = PART_OQH - 1
WHERE PART_CODE = ‘C’
COMMIT;
Figure 4
Page 9 of 12
We assume that product ‘ABC’ has a PROD_QOH = 23 at the start of the transaction and
that the transaction is representing the addition of 1 new product. We also assume that
PART components “A”, “B” and “C” have a PROD_QOH equal to 56, 12, and 45
respectively. (9 marks)
Figure 5
Page 10 of 12
Question 24 – Structured Query Language (17 marks)
Use the following description and the ERD given below (see Figure 6) to answer parts
(A) to (E) of this question. Write SQL statements to answer each part and your SQL
statement should be written for a MySQL database.
You are given a database that is used by a video library to store data about movies, copies
of each movie, borrowers, and renting of the movies. A movie can have one or more
copies. Each copy can be rented by one of more borrowers.
Figure 6
Page 11 of 12
(A) List the details of all borrowers, sorted by their last name in increasing order.
(2 marks)
(B) List the number and names of all borrowers that have not borrowed any movies.
(3 marks)
(C) List the code(s), name(s) and the price of the most expensive movie(s) [Hint: use the
movie_charge column]. (3 marks)
(D) List the movie code, name and the number of copies of each movie that has more
than two copies. (4 marks)
(E) List the movie code and name of all movies where at least one copy of the movie has
never been borrowed. (5 marks)
Page 12 of 12
IS222 – Final Exam Semester 1 2012