B.Sc. Degree: Sri Lanka Institute of Information Technology

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Sri Lanka Institute of Information Technology

B.Sc. Degree
in

Information Technology
Mid term Examination
Year 2, Semester 2 (2013)

Object Relational Database Systems (N210)


Duration: 1 Hour

Instruction to Candidates:

This paper contains 2 questions on 5 pages without the cover page.


Answer all questions on this paper itself.
Read all questions before start answering.
The total marks obtainable for this examination is 100.
This is a closed book examination.

Page 1 of 6

Question 1

(52 marks)

Consider the following relational schema about doctors, patients and the various tests that were
conducted on them.

Object types:
Doctor_t (docId:char(10), dname:varchar2(50), specialization:varchar2(25))
test_t (testId:varchar(10), tDate:date, Doc: ref doctor_t, result:varchar(12), cost:real)
test_tlb as a table of test_t
Patient_t (pId:char(10), pname:varchar2(50), dob:date, phone:char(10), tests test_tlb)

Tables:
Doctors of Doctor_t(docId primary key)
Patients of Patient_t(pId primary key) nested table tests store as test_ntb;

Doctors table contains information about all doctors at the hospital. The attributes of doctors are doctor
ID (docId), name (dname) and field of specialization (specialization). The Patients table contains
information about the patients visiting the hospital. The attributes of Patients are patient ID (pId), name
(pname), date of birth (dob), phone number (phone) and tests done to the patient (tests). The tests
attribute of patients table is a nested table of type test_tlb. The attributes of the test_tlb are test Id
(testId), test date (tDate), doctor who conducted the test (Doc), which is a reference to an object of type
doctor_t, and cost of test (cost).

a) Select the patients who a got a positive test result for the test T2 that was conducted after 1st
of January 2013. Display the patient name, test Id, date and the test result.
(8 marks)

Page 2 of 6

b) Select the patients who have spent more than Rs 5000 in total for the tests. Display the patient
ID, patient name and the total cost.
(8 marks)

c) Insert a new test for the patient with patient ID 1001. (Patient record with Id 1001 already exist
in Patient table). Test Id is t5 and it was conducted on 12th July 2013 at a cost of Rs 1200 by the
doctor with Id D100. The result was positive.
(8 marks)

d) Select the patients who got tests conducted by doctors with Endocrinologist specialization.
Display the patient name, doctor name and specialization.
(8 marks)

Page 3 of 6

e) It is required to add a member function to compute the number of tests conducted on a patient.
Write Oracle SQL statements to modify the Patient_t by adding this specification.
(12 marks)

f)

Using the method defined above write a SQL statement to display the patient Id, patient name
and the number of tests conducted on them by a doctor with a Cardiologist specialization.
(8 marks)

Page 4 of 6

Question 2

(48 marks)

The Entity Relationship (ER) diagram below represent that a diagram consists of Shapes. A shape can be
a Circle or a Square.

ShapeID

color

DrawnIn

Shape
Diagram
radius

length
name

Circle

Square

width

a) Map this ER diagram to an Oracle object relational schema. Show the steps in your mapping.
Indicate all Ref types.
(20 marks)

Page 5 of 6

b) Write Oracle SQL statements to create the Shape type. Shape type has a not instantiable Map
member method Area() to calculate the area of a shape.
(10 marks)

c) Write Oracle SQL statements to create Square type. Override the Area () method in Square type.
(12 marks)

d) Square is a table of Square type. Write an Oracle SQL statement to list the unique squares in the
table.
(6 marks)

Page 6 of 6

You might also like