DBMS
DBMS
Question One
i. Databases are essential components in software development process where the organisational
data are stored in a well-organised manner. Write down advantages of the databases over
traditional flat files. (3 marks)
ii. Draw a relational database table called “Student”. Indicate (Colum headings / Attributes),
(Rows/ Tuples/ Records), Fields, Primary key. (3 marks)
iii. What is a Database Management System ? Give examples for 3 DBMS’s. (3 marks)
iv. What is a composite key ? Write down an example for composite key. (3 marks)
v. What is a foreign key. Explain how the foreign key helps you to create a link between two
tables. (3 marks)
Question Two
Scenario:
“Weekday Special” is a restaurant which is opened on week days. It has variety of items for the
customers to enjoy Sri Lankan foods. “Weekday Special” has an automated system to maintain
their restaurant details and transactions.
They have a file called “Menu” which maintains their menu details having menuCode and
menuName. To record food item details in each menu, a file called “FoodItem” is maintained
which has itemCode, itemName, menuCode and price.
Customers can reserve tables at the restaurant and those details are maintained in “Reservation
File”. It contains the details reservationCode, customerName, address, contactNo, advancePay.
When the dining is finished, customer pays the bill to the waiter. Waiter details are maintained in
the “Waiter” file which contains waiterId, waiterName. Customer receipt details are maintained in
Page 1 of 4
the “Receipt” file which contains the receiptNo, menuCode, foodItem, paymentType and the
amount. Customer can make payment in two ways either by “cash” or “credit card”. Each payment
type is maintained in two separate files having paymentCode and amount.
a. Draw an Enhanced ER diagram for the given scenario. Note: Other than the entities in the
given scenario, you could include additional entities if required.
b. Map the Enhanced ER in to the relational schema (You should specify Table Name,
Primary key, Foreign key/s of each table clearly. (20 marks)
Question Three
Consider the following relation and answer the questions below.
The below table contains patient details who were admitted to a hospital. Due to viral attack of
fever and cough, some of them have admitted more than once.
Patient
Page 2 of 4
Question Four
Student
Stno stname stream uniCode Lec_code
St001 Nimal Biology UC 100
St002 Kamal Maths UJ 101
St003 Saman Commerce UJ 103
Lecturer
Lec_code Lecturer Name specialization uniCode
100 Perera Chemistry UC
101 Victor Physics UR
102 Gihan Economics UJ
103 Sanath Finance UJ
University
City
city province
Colombo Western
Matara Southern
Jayawardanapura Westerm
Peradeniya Central
Page 3 of 4
6. Display “University Name” of the lecturer’s who are teaching “Maths” stream students
(2 marks)
7. Display uniCode and Province of each University. (2 marks)
8. Display Name of the University of the lecturers whose name is starting with
V and who are specialized in “Physics”. (2 marks)
9. Display student name and stream of the students whose lecturers studied at University of
Colombo. (2 marks)
10. Display University name of the lecturers who are teaching for the
Students having the name starting with “S”. (2 marks)
11. Write SQL query to create a Database called University. (2 mark)
12. Write SQL query to create a table called Student. Use your own data types and field sizes
(2 marks)
13. Update the stream of student St002 to Computer Science (2 marks)
Question Five
WITH
Insert into stud values (stno, stna, address, tel, mark, grade)
i. The above SP has some errors. Correct the mistakes and write down the
correct SP in answer sheets. (4 marks)
ii. Mark parameters in the above stored procedure. (2 marks)
iii. What is the purpose of these parameters. (2 marks)
2. Write a stored procedure which updates student mark in the student table. (3 marks)
3. Why do we fire triggers on Insert, Update, Delete functions in databases? (3 marks)
4. Write a trigger for INSERT operation in “emp” table.
(You could define your own field names for the table.) (3 marks)
5. Briefly explain how to improve security of a database. (3 marks)
Page 4 of 4