Uploaded by Htut Myat Yee

Q-3 Marking

advertisement
Department of Advanced Science and Technology
University of Computer Studies (Thaton)
Semester (III) (B.C.Sc. / B.C.Tech.) Examination
Database Management System (CST-2124)
September, 2023
Answer all questions.
Time allowed:
3 hours
I.
II.
Choose the correct answer for each of the following statements.
1. (c)
11. (b)
2. (b)
12. (b)
3. (a)
13. (c)
4. (d)
14. (c)
5. (b)
15. (c)
6. (c)
16. (d)
7. (d)
17. (c)
8. (c)
18. (a)
9. (b)
19. (b)
10. (d)
20. (c)
𝟏
𝟏
1. fid, flight_date, time, src, destination (𝟐 mark) ( src = “Chennai” (𝟐 mark) ^ destination = “New Delhi”
𝟏
𝟏
(𝟐mark) (flight)) (𝟐 mark)
𝟏
𝟏
2. fid, flight_date, time, src, destination(𝟐 mark) ( flight_date = “01/11/2023” (𝟐 mark)
𝟏
“01/11/2023” (
𝟐
^ flight_date =
𝟏
mark) (flight)) (𝟐 mark)
𝟏
3. fid(𝟐 mark) (pid=123
^ destination = “Chennai”
𝟏
(𝟐 mark)
𝟏
^ flight_date < “06/10/2023”
𝟏
(𝟐 mark)
𝟏
(flightβ‹ˆfid=fid booking) (𝟐 mark) β‹ˆpid=pid passenger) (𝟐 mark)
𝟏
4. pname (passenger) ( mark) - (pname (passengerβ‹ˆpid=pid booking)) (𝟏 mark)
𝟐
𝟏
𝟏
𝟏
𝟐
𝟐
𝟐
5. agency_name( mark) (agency_city=pass_city ^ pid= 123 ( mark) (agencyβ‹ˆaid=aid booking) (
𝟏
mark) β‹ˆpid=pid passenger) (𝟐 mark)
III.
𝟏
(a) create table customer ( 𝐦𝐚𝐫𝐀)
𝟐
𝟏
(cid varchar (5), cname varchar (30), address varchar (20), (𝟐 𝐦𝐚𝐫𝐀)
primary key (cid)); (1 mark)
𝟏
create table meter_box (𝟐 𝐦𝐚𝐫𝐀)
𝟏
(mbid varchar (5), type varchar (10), keeps_tip int, (𝟐 𝐦𝐚𝐫𝐀)
primary key (mbid)); (1 mark)
𝟏
create table unit_price (𝟐 𝐦𝐚𝐫𝐀)
𝟏
(upid varchar (5), mbid varchar (5), ranges varchar (25), price int, (𝟐 𝐦𝐚𝐫𝐀)
primary key (upid), (𝟏 𝐦𝐚𝐫𝐀)
𝟏
foreign key (mbid) references meter_box (mbid) (𝟐 𝐦𝐚𝐫𝐀)
𝟏
on delete cascade on update cascade); (𝟐 𝐦𝐚𝐫𝐀)
𝟏
create table receipt (𝟐 𝐦𝐚𝐫𝐀)
(rid varchar (5), cid varchar (5), upid varchar (5), useunit int, dueDate int,
𝟏
amount int, primary key (rid), (𝟐 𝐦𝐚𝐫𝐀)
𝟏
foreign key (cid) references customer (cid) (𝟐 𝐦𝐚𝐫𝐀)
𝟏
on delete cascade on update cascade, (𝟐 𝐦𝐚𝐫𝐀)
𝟏
foreign key (upid) references unit_price (upid) (𝟐 𝐦𝐚𝐫𝐀)
𝟏
on delete cascade on update cascade); (𝟐 𝐦𝐚𝐫𝐀)
III.
(b)
𝟏
1. select cname (𝟐 𝐦𝐚𝐫𝐀)
𝟏
from customer (𝟐 𝐦𝐚𝐫𝐀)
𝟏
where address = ‘SanChaung’; (𝟐 𝐦𝐚𝐫𝐀)
2. select type, count(ranges) (𝟏 𝐦𝐚𝐫𝐀)
from meter_box as M, unit_price as U (𝟏 𝐦𝐚𝐫𝐀)
𝟏
where M.mbid= U.mbid (𝟐 𝐦𝐚𝐫𝐀)
𝟏
group by M.type; (𝟐 𝐦𝐚𝐫𝐀)
𝟏
3. select customer.cname ; ( 𝐦𝐚𝐫𝐀)
𝟐
𝟏
from customer, receipt; (𝟐 𝐦𝐚𝐫𝐀)
𝟏
where receipt.cid=customer.cid; (𝟐 𝐦𝐚𝐫𝐀)
𝟏
and amount > 30000; (𝟐 𝐦𝐚𝐫𝐀)
𝟏
4. update unit_price (𝟐 𝐦𝐚𝐫𝐀)
𝟏
set price=100 (𝟐 𝐦𝐚𝐫𝐀)
𝟏
where ranges = ‘75-100’(𝟐 𝐦𝐚𝐫𝐀)
and mbid = (select mbid from meter_box where type= ‘business’); (𝟐 𝐦𝐚𝐫𝐀)
𝟏
5. update customer (𝟐 𝐦𝐚𝐫𝐀)
𝟏
set address =‘NorthDagon’(𝟐 𝐦𝐚𝐫𝐀)
𝟏
where address =‘SanChaung’; (𝟐 𝐦𝐚𝐫𝐀)
𝟏
6. delete(𝟐 𝐦𝐚𝐫𝐀)
𝟏
from receipt (𝟐 𝐦𝐚𝐫𝐀)
where dueDate < ‘2023-03-31’; (𝟏 𝐦𝐚𝐫𝐀)
𝟏
𝟏
7. select meter_box.type(𝟐 𝐦𝐚𝐫𝐀), unit_price.ranges (𝟐 𝐦𝐚𝐫𝐀)
from meter_box, unit_price, receipt(𝟏 𝐦𝐚𝐫𝐀)
𝟏
where receipt.upid=unit_price.upid( 𝐦𝐚𝐫𝐀)
𝟐
𝟏
and receipt.mbid=meter_box.mbid(𝟐 𝐦𝐚𝐫𝐀)
𝟏
and unit_price.price between 50 and 70; (𝟐 𝐦𝐚𝐫𝐀)
𝟏
8. create view Below30 as (𝟐 𝐦𝐚𝐫𝐀)
𝟏
(select customer.cname, customer.address(𝟐 𝐦𝐚𝐫𝐀)
𝟏
from customer, meter_box, unit_price, receipt(𝟐 𝐦𝐚𝐫𝐀)
𝟏
where customer.cid=receipt.cid(𝟐 𝐦𝐚𝐫𝐀)
𝟏
and meter_box.mbid=receipt.mbid(𝟐 𝐦𝐚𝐫𝐀)
𝟏
and unit_price.upid=receipt.upid(𝟐 𝐦𝐚𝐫𝐀)
𝟏
and useunit < 30(𝟐 𝐦𝐚𝐫𝐀)
𝟏
and type= ‘domestic’); (𝟐 𝐦𝐚𝐫𝐀)
9. create user Smith@localhost (𝟏 𝐦𝐚𝐫𝐀) identified by ‘Smith123’; (𝟏 𝐦𝐚𝐫𝐀)
10. grant select (1 𝐦𝐚𝐫𝐀)
𝟏
on Below30 (𝟐 𝐦𝐚𝐫𝐀)
𝟏
to Smith@localhost; (𝟐 𝐦𝐚𝐫𝐀)
IV. (a)
student
sid
s_name
program
coruse_offerings
time
sec_no
room
year
semester
enrols
grade
teaches
instructor
iid
i_name
dept
title
is offered
course
course_no
syllabus
title
credits
IV. (b)
(1 mark)
(1 mark)
(1 mark)
instructor
student
IID
Iname
SID
Sname
advise
𝟏
(𝟐 𝐦𝐚𝐫𝐀)
𝟏
(𝟐 mark)
(1 mark)
IV. (c)
(1 mark)
(1 mark)
country
capital
Country_ID
Country_name
𝟏
(𝟐 𝐦𝐚𝐫𝐀)
V.
Capital_ID
Capital_name
has
𝟏
(𝟐 mark)
(a) 1. This table is unnormalized table. (1 mark)
2. It is necessary to further normalize the generated tables from question (1) to1NF
(1 mark) because this table has multiple value. (1 mark)
EmployeeCode EmployeeName ProjectName
101
Jolly
Project101
(𝟏 mark)
101
Jolly
Project102
102
Rehan
Project103
102
Rehan
Project104
3. It is necessary to further normalize the generated tables from question () to 2NF
(1 mark)because this table has partial dependency. (1 mark)
Employee_Project table
Employee table
EmployeeCode ProjectCode
EmployeeCode EmployeeName
101
P1
(𝟏 mark)
101
P2
102
P3
102
P4
Project table
ProjectCode
P1
Project101
(𝟐 mark)
Project102
P3
Project103
P4
Project104
Jolly
102
Rehan
(𝟏 mark)
ProjectName
P2
101
V.
(b) 1. Closure {id, name}+
𝟏
1. result ={id, name}(𝟐mark)
𝟏
1st loop for 3 times, (𝟐marks)
1. id→name, gender
2. name→gender
3. age, DOB→gender
result = {id, name, gender}
no change
no change
𝟏
(𝟏 𝟐 mark)
𝟏
2nd loop for 3 times, (𝟐marks)
1. id→name, gender
2. name→gender
3. age, DOB→gender
no change
no change
no change
𝟏
(𝟏 𝟐 mark)
𝟏
So, {id, name}+ = {id, name, gender}(𝟐marks)
2. Show that the FD id, DOB→gender holds for
1. id→name, gender
2. id, DOB→name, gender, DOB (1 mark)
3. id, DOB→gender(1 mark)
(given) (1 mark)
(1, Augmentation) (1 mark)
(2, Decomposition) (1 mark)
Download