Csi ZG518 Ec-2
Csi ZG518 Ec-2
Mid-Semester Test
(EC-2 Regular)
Q.1Set.(A)
Convert the ER to relational schemas.
Grading:
Entities, attributes and PK: 3 marks
Relationship: 4 marks
Referential Integrity Constraints: 3 marks Total marks:10 marks
Q.1Set.(B)
Convert the ER to Relational Schema.
Grading:
Entities, attributes and PK: 3 marks
Relationship: 4 marks
Referential Integrity Constraints: 3 marks Total marks : 10 marks
Q.1Set.(C)
Grading:
Entities, attributes and PK: 3 marks
Relationship: 4 marks
Referential Integrity Constraints: 3 marks Total marks : 10 marks
Q.2Set.(A)
a.
Consider a relation schema R with attributes ABCDEFGH with functional dependencies S:
S = {B → CD; BF → H; C → AG; CEH → F; CH → B}
Which of these functional dependencies violate BCNF (Boyce-Codd Normal Form)?
(4 marks)
b.
Consider a relation R(A, B, C) with FD's AB → C, AC → B, BC → A.
Determine all the keys of relation R. Is the relation R in BCNF? ( 4 marks)
Total marks: 8 marks
Q.2Set.(B)
Consider a relation Movies_Screened with attributes Theatre, Movie, Day, Time, and
Certificate. Sample tuples are as follows:
Each movie is assigned a certificate by the Indian Board of Film Certification; the certificate
value 15 means that nobody younger than 15 years of age can see this movie in a cinema. The
same theatre can show a movie on multiple times during a day, and may show different
movies at the same time (on different screens).
(a) Does this relation violate the second normal form requirements? Explain. (4 marks)
(b) Decompose this relation into BCNF, and explain why the resulting relations are in BCNF.
(4 marks)
Total marks: 8 marks.
Q.2Set.(C)
Let F1 = {A → C, AC → D, E → AD} and F2 = {A → CD, E → AH}. Are F1 and F2 are
equivalent? Total Marks: 8 marks
Q.3Set.(A)
Consider a relation REPAYMENT with the following schema;
REPAYMENT(BORROWER_ID, NAME, ADDRESS, LOANAMOUNT,
REQUESTDATE, REPAYMENT_DATE, REPAYMENT_AMOUNT)
Assume that this table records the repayment of loans by the borrowers. A borrower may
have multiple entries if he/she has paid multiple installments.
a. Find all the records with information on repayments from the borrower with id equal to
42, and where the lent amount exceeds 1000. (1 mark)
b. Find the total amount repaid for every address in the repayment table. (1 mark)
c. Delete all information on the completed loans. (Note: you can find the status of the loan
by summing the total repaid amount. If the total repaid amount is equal to the loan
amount, then you would say that the loan is ended.) (1 mark)
d. Find all the borrower names who has unique address. (ie., you should not count the
borrowers who are from the same address) (1 mark)
e. Find the total number of repayments made by every borrower. (2 mark)
Total Marks: 6 marks
Q.3Set.(B)
Consider the following:
VISITORS (Visitor Id, Name, Age, Gender, Address, Contact_no, Email, Entry_time,
Exit_time, Date_of_visit, Mode_of_Transport)
EVENTS (Event_ID, Event_Name, Capacity, Timings, Category)
EMPLOYEE (Emp_ID, Emp_Name, Address, Contact_No, Gender, Department, Shift,
Salary, DOB, Join_Date, Event_Id)
MAINTENANCE_PROBLEMS (Complaint_Id, Complaint_Name, Date_of_complaint,
Status, Date_of_completion, Employee_Id, Event_Id)
BOOKINGS (Ticket_No, Payment_Mode, Card_type, Price_Before_discount,
Price_After_Discount, No_of_visitors, Visitor_Id, Event_Id)
Q.3Set.(C)
Consider the Relational model:
Write SQL and RA for the following:
a. Retrieve the names of all borrowers who do not have any books checked out .
(1 mark)
b. For each book that is loaned out from the "Sharpstown" branch and whose DueDate is
today, retrieve the book title, the borrower's name, and the borrower's address.
(1 mark)
c. For each library branch, retrieve the branch name and the total number of books
loaned out from that branch. (1 mark)
d. Retrieve the names, addresses, and number of books checked out for all borrowers
who have more than five books checked out. (1 mark)
e. For each book authored (or co-authored) by "Stephen King", retrieve the title and the
number of copies owned by the library branch whose name is "Central" (2 marks)
Total marks: 6 marks
Q.4Set.(A)
A file has r = 30,000 Patients’ record of fixed length. Each record has the following fields:
Name (30 bytes), SSN (9 bytes), Address (40 bytes), PHONE (10 bytes), Birth_date (8
bytes), Gender (1 byte). An additional byte is used as a deletion marker. The file is stored on
the disk whose parameters are given [ie.block size B = 512 bytes; interblock gap size G =
128 bytes; number of blocks per track = 20; number of tracks per surface = 400; a disk pack
consists of 15 double-sided disks, seek time is 30msec, rotational delay=12.5]
a. Calculate the record size R in bytes. (1 mark)
b. Calculate the blocking factor bfr and the number of file blocks b, assuming an unspanned
organization. (1 mark)
c. Calculate the average time it takes to find a record by doing a linear search on the file
(i) if the file blocks are stored contiguously, and double buffering is used (1 mark)
(ii) the file blocks are not stored contiguously. (1 mark)
d. Assume that the file is ordered by SSN; by doing a binary search, calculate the time it
takes to search for a record given its SSN value. (2 mark)
Total: 6 marks
Q.4Set.(B)
Draw the Hash table using linear hash where h(k)=10 mod k, for the following data to be
stored on disks.
Record no name
45 Jansi
89 Tania
94 Jasmine
373 Mona
a. Draw the Hash table for the above data where it keeps track of record number fetched
from disk for given name. (2 marks)
b. Mars is fetched with record number 56. Redraw the Hash Table. (2 marks)
c. Tania is deleted and so its record number as well. Redraw the Hash table. (2 marks)
Total marks: 6 marks
Q.4Set.(C)
GENO corporation has branches all over India and has many departments. It uses the B+
tree for the following data:
Pname Plocation Departmentname
E45 chennai Distributed
computing
H59 Bangalore Fluid mechanics
F47 Delhi Space
G20S Pune Aviation
a. Draw the B+ tree for the above data where Pname and Plocation is used. (2
marks)
b. F47 is completed and deployed. And the records related to this is removed
from organization’s records. Redraw the B+ tree. (2 marks)
c. K393L is the new project at Vellore and is handled by “Simulation”
department. Redraw the B+ tree. (2 marks)
Total marks: 6 marks
===============XXXXXX===================