Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
t
,-n
SUIT.
~JIII~
11th
August 2007
Duration: 1 Hour
(Time 9.00 a.m. -lO.OO'a.m.)
Instructions to Candidates
This paper contains FOUR (4) questions on THREE Pages.
Answer ALL questions.
The entire exam is worth 50 points.
QUESTION 1.
Each row in an Oracle object table has an object identifier that uniquely identifies the
row. Then what is the purpose of specifying a primary key on an object table?(2 marks)
QUESTION 2.
This question requires you to use the inheritance features of Oracle object relational
system.
Consider a type named emp_type that has attributes, (eid: char(8), ename:
varchar(15), phone: char(10.
Let hourlyEmp_type be a subtype of emp_type with attributes, (hourly_wages: real,
hours_worked: integer).
(a). Write Oracle object SQL statements to create these two types. (2 marks)
(b). Assuming that a table named employees of emp_type has been created, insert a
hourlyEmp _type tuple into it with attribute values of eid: 12354326, ename: Dilum
Perera, phone: null,1250.00, 8) (2 marks)
(e). Assuming there may b~ data on _type and others in the ttmployees table of
emp_type, write an Oracle object SQL statement to retrieve the eid and ename of
only employees with hours~workedmore than 8 (8 hours). (4 marks)-
QUESTION 3.
Consider the following object relational database schema for insurance policies
database:
Object types:
Customer_t (cid: char(6), name: varchar(l5), birthdate: date, phone: char(lO),
address: varchar(50
Car_t (regno: char(9), make: varchar(12), model: varchar(10), mdate: date, owner: ref
customer_t, value: number(8,2
Claim_t (claimno: char(12), cdate: date, amount: number(8,2), claimant: ref customer)
Claim ntab table of claim - t
Policy_t (pid: char(7), sdate: date,edate: date, inscar: refcar_t, premium: number(6,2),
claims: claim _ntab)
Tables:
Customers of Customer _t (cid primary key)
Cars of car_t (regno primary key, owner references Customers)
Policies of policy _t (pid primary key, inscar references Cars)
Nested table claims store as claims ntable
a
The Customers, Cars, and Policies tables contain tuples for all customers, cars and
policies respectively.
a Attributes
of Customers are customer id (cid), name, date of birth, phone and address.
Attributes of Cars are registration number (regno), make, model, date of manufacture,
owner ofthe car, and insured value of the car.
a Attributes
of Policies policy id (pid), starting date, ending date, insured car, annual
a
queries (use
(5 marks)
(b). Write Oracle object SQL to insert a claim against an existing policy that has a pid of
SL12354, given the following claim details>elaim number: 001, claim date: 12 July
2004, claim amount: 2000, and customer id of claimant: S25431. Assume that the
claimant is already present as a customer in the database. (6 marks)
(c).
Write Oracle object SQL to calculate the renewal premium for a given policy- in
the database using the following logic:
If the policy had no claims or the total claim is less than 1000, then the new
premium is the same as the current premium. If the total claim on a policy is greater
than or equal to 1000, then the new premium is to be 20% more than the current.
(15 marks)
(d).
Using the method defined above in (c), get the renewal premium for the policy of a
car with registration number SLA984. (3 marks)
QUESTION 4
The Entity-Relationship model given below shows a part of the database requirements
of a hospital. Map this ER model to an Oracle object relational schema. Show the steps
in your mapping. Indicate all REF types, as well as primary and scope refs.
The built-in data types need not be specified. Also, it is not necessary to write
CREATE TYPE or CREATE TABLE statements. (11 marks)
Hospital Visits
docCharge