0% found this document useful (0 votes)
32 views12 pages

IS222 2010 Sol

IS222_2010_Sol

Uploaded by

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

IS222 2010 Sol

IS222_2010_Sol

Uploaded by

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

The University of the South Pacific

Serving the Cook Islands, Fiji, Kiribati, Marshall Islands, Nauru, Niue, Samoa, Solomon Islands, Tokelau, Tonga, Tuvalu, and Vanuatu.

School of Computing, Information and


Mathematical Sciences
Solution Guide

IS222: Database Management Systems

FINAL EXAMINATION – SEMESTER 1, 2010

Time Allowed 3 hours plus 10 minutes reading

100 marks (50% of final grade)


INSTRUCTIONS

1. This exam has two sections:


a. Section A: 20 marks
b. Section B: 80 marks
2. Answer all questions in sections A and B. There are no choices.
3. The answers to questions 1 – 10 in section A must be clearly written on the
Special Answer Sheet provided together with this paper and that sheet should be
handed in with your answer book.
4. Answer all questions in Section B in the answer booklet provided.
5. This exam is worth 50% of your overall mark. The minimum mark to pass the
final exam is 20/50%.
6. There are 7 pages in this booklet including this page.

Page 1 of 12
Section A – Multiple Choice Questions (Each question has only one answer and is worth 2 marks)

1. Any attribute that is part of a key is known as a ____.


a. key attribute
b. logical attribute
c. key determiner
d. selector

2. A CUSTOMER table’s primary key is CUS_CODE. The CUSTOMER primary key column
has no null entries, and all entries are unique. This is an example of ____ integrity.
a. entity
b. referential
c. complete
d. null

3. A ____ entity is composed of the primary keys of each of the entities to be connected.
a. bridge
b. composite
c. unary
d. binary

4. From a structural point of view, 2NF is better than ____.


a. 1NF
b. 3NF
c. 4NF
d. BCNF

5. A relation is not in 1NF if ____.


a. it has multiple candidate keys
b. all of the key attributes are defined
c. there are repeating groups in the table
d. all attributes are dependent on the primary key

6. A(n) ____ is an alternate name given to a column or table in any SQL statement.
a. alias
b. data type
c. stored function
d. trigger

7. The ____ special operator is used to check whether an attribute value is null.
a. BETWEEN
b. IS NULL
c. LIKE
d. IN

Page 2 of 12
8. All transactions must display ____.
a. atomicity, serializability, and durability
b. durability and isolation
c. serializability, durability, and isolation
d. atomicity, durability, serializability, and isolation

9. As long as two transactions, T1 and T2, access ____ data, there is no conflict, and the order
of execution is irrelevant to the final outcome.
a. shared
b. common
c. unrelated
d. locked

10. ____ are rules that applies to the two-phase locking protocol.
a. Two transactions cannot have conflicting locks.
b. No unlock operation can precede a lock operation in a different transaction.
c. No data is affected until all locks are released.
d. No data is affected until the transaction is in its locked position.

Page 3 of 12
Section B – Short Answer and Case Study Questions

Question 11 – Entity Relationship Modeling (18 marks)

Use the following description to answer parts (A) to (C) of this question

AcuteRentals is a car rental company. The company is planning to develop a database


that will store car rental data and the servicing history.

AcuteRentals store data about the customers who rent out the cars. The details about the
customer that is kept by the company include the Customer Number (unique for each
customer), the customer’s name, residential and postal addresses, and home and work
phone numbers.

A customer can take any number of cars over a period of time but is limited to taking out
one car at a time. At any given point in time, a customer can rent only one car. When
renting out a car to a customer, AcuteRentals records the rent number (unique for each
rent record) customer number, date, car registration, pick up date, return date, and the
total charge.

When a car is returned by a customer it is inspected before it is made available to other


customers. Even a new car is inspected before it is given to the first customer. Inspection
means that the car is checked to make sure that it is in a good condition. Vehicle
Inspectors check the cars and record the inspection number (unique for each inspection)
registration number, the date of inspection, mileage (the total distance travelled by the
car), and the Inspector ID of all inspectors who have checked the car. This means that a
car can be checked by many inspectors, and it is possible for an inspector to check one or
many cars. For each inspector, the company records the Inspector ID, first and last
names.

For each car the company records car registration (unique), description, and mileage.

(A) What is a business rule? (1 mark)

A business rule is Brief, precise, and unambiguous description of a policy, procedure, or


principle within a specific organization.

(B) Identify all possible business rules for the above case study. (6 marks)

1. A customer can rent one or many cars and each car can be rented by no or many
customers
2. A car can have one or many inspection, but during a particular inspection only
one car is checked.
3. A can be inspected by one or many inspectors and each inspector can inspect no
or many cars.

(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. (16 marks)

Page 5 of 12
Question 12 – Normalization (18 marks)

A small medical clinic stores data about the medicine/drug that is given out to patients by
the doctors using the following table. The patients receive the drug when they come to
see a doctor.

Study the following table and use it to answer parts (A) to (C) of this question.

Attribute Sample 1 Sample 2 Sample 3 Sample 4 Sample 5 Sample 6


doc_id 34409 34409 32445 32445 38995 32445
doc_lname Washington Washington Jorgensen Jorgensen Minh Jorgensen
doc_fname Dennis Dennis Annelise Annelise Tran Annelise
pat_num 101 101 102 102 107 107
pat_lname Lewis Lewis Vandam Vandam Diante Diante
pat_fname Rhonda Rhonda Rhett Rhett Jorge Jorge
pat_dob 3/19/2005 3/19/2005 11/14/1958 11/14/1958 8/21/1974 8/21/1974
visit_num 1 2 1 2 1 2
drug_code KO15 DRO DRZ OLE KO15 DRO
Koliabar Droalene Druzocholar Oleander- Koliabar Droalene
drug_name Oxyhexalene Chloride Cryptolene Drizapan Oxyhexalene Chloride
drug_price 65.75 111.89 18.99 123.95 65.75 111.89
visit_date 11/14/2007 11/14/2007 11/12/2007 11/15/2007 11/14/2007 12/20/2007

(A) Identify the repeating group in the table given above. (2 marks)

Visit_num, drug_code, drug_name, drug_price, visit date

Page 6 of 12
(B) Draw a dependency diagram showing all dependencies. (8 marks)

doc_id

doc_lname
doc_fname
pat_num
pat_lname
pat_fname
pat_dob
visit_num
drug_code

drug_name
drug_price
visit_date

2 mark for each type of dependency

Page 7 of 12
(C) Convert your table structure shown in part (B) to 3NF and draw the new dependency
diagrams. (8 marks)

FDs are NOT shown. Please create these yourself.

doc_id doc_lname doc_fname

pat_num pat_lname pat_fname pat_dob

drug_code drug_name drug_price

doc_id pat_num visit_num drug_code visit_date

Page 8 of 12
Question 13 – Structured Query Language (39 marks)

Use the following description and the database schema given below to answer the parts
(A) and (H) of this section. Write SQL statements to answer each part.

Assume the following database is used to store the sales data for a company.

Note: This is the same database you have used to do your labs.

Assume the following fields are numeric:


CUS_CODE, CUS_BALANCE, INV_NUMBER, LINE_NUMBER, LINE_UNITS,
LINE_PRICE, P_CODE, P_QOH, P_MIN, P_PRICE, P_DISCOUNT, V_CODE

The other files are character or date based.

(A) List the customer code, customer name (first name + initial + last name), cus_balance
sorted by customer last name in ascending order. (4 marks)

select cus_code, cus_fname & " " & cus_initial & " " &
cus_lname As [Name], cus_balance
from customer
order by cus_lname;

Page 9 of 12
(B) List the product code and description of all products that are below the minimum
required quantity. (4 marks)

SELECT p_code, p_descript


FROM product
WHERE p_qoh<p_min;

(C) List the vendor code, name, and the number of products that is supplied by the
vendor. Include those vendors that do not supply any products. (4 marks)

SELECT v.v_code, v_name, count(p.v_code) AS [Products


Supplied]
FROM product AS p RIGHT JOIN vendor AS v ON
p.v_code=v.v_code
GROUP BY v.v_code, v_name;

OR

SELECT v.V_CODE, v.V_NAME, (select count(p.v_code)


from product p where p.v_code=v.v_code) AS [Products
Supplied]
FROM vendor AS v;

(D) List the product code and description of the products with minimum and maximum
prices. (4 marks)

SELECT p_code, p_descript, (select min(pb.p_price) from


product pb) as [min or max price]
FROM product
WHERE p_price = (select min(pb.p_price) from product pb)

UNION

SELECT p_code, p_descript, (select max(pb.p_price) from


product pb) as [min or max price]
FROM product
WHERE p_price = (select max(pb.p_price) from product pb);

Page 10 of 12
(E) List the invoice number, invoice date, total number of lines in that invoice and the
total sales amount for that invoice. Sort the list by the total invoice amount in
decreasing order and list only those invoices where the total invoice amount is greater
than 100. (6 marks)

SELECT i.inv_number, inv_date, count(line_number) AS


[Total Lines], sum(line_units*line_price) AS [Total
Amount]
FROM invoice AS i, line AS l
WHERE i.inv_number=l.inv_number
GROUP BY i.inv_number, inv_date
HAVING sum(line_units*line_price) > 100
ORDER BY sum(line_units*line_price) DESC;

(F) List the vendor code, vendor name, and vendor phone of all vendors sorted by the
name of the vendor in ascending order. (4 marks)

SELECT v_code, v_name, v_phone


FROM vendor
ORDER BY v_name;

(G) Given below is the data dictionary for the Enroll entity. Use it to write the SQL
statement that will create the Enroll table. (5 marks)

Table Attribute Type Required PK/FK Ref Table


Enroll OfferingID CHAR (5) Y PK/FK Offering
StudentID CHAR (9) Y PK/FK Student
EnrollGrade VARCHAR (2)

MS Access
CREATE TABLE enroll (
offeringid CHAR(5) NOT NULL,
studentid CHAR(9) NOT NULL,
enrollgrade VARCHAR(2),
CONSTRAINT enroll2_pk PRIMARY KEY(offeringid,studentid),
CONSTRAINT enroll_fk1 FOREIGN KEY (offeringid) REFERENCES
offering);

MySQL
CREATE TABLE enroll2(
offeringid CHAR(5) NOT NULL,
studentid CHAR(9) NOT NULL,
enrollgrade VARCHAR(2),
CONSTRAINT enroll2_pk PRIMARY KEY(offeringid,studentid),
CONSTRAINT enroll_fk1 FOREIGN KEY (offeringid) REFERENCES
offering(offeringid));

Page 11 of 12
(H) Change the enroll table by adding a new column named enrollmark which is of
Double datatype. It is an optional field. (4 marks)

ALTER TABLE enroll ADD COLUMN enrollmark double;

(I) List the invoice number, invoice date, product code and description, line units and the
line price details for invoice number 1006. (4 marks)

SELECT i.inv_number, inv_date, p.p_code, p_descript,


line_units, line_price
FROM invoice AS i, product AS p, line AS l
WHERE i.inv_number = l.inv_number and p.p_code = l.p_code
and i.inv_number=1006;

Page 12 of 12

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy