You are on page 1of 5
M2102 CARDIFF UNIVERSITY EXAMINATION PAPER Academic Year: 2013-2014 Examination Period: Autumn Examination Paper Number: M2102 Examination Paper Title: Database Systems Duration: 2 hours Do not turn this page over until instructed to do so by the Senior Invigilator. Structure of Examination Paper: ‘There are 5 pages. There are 4 questions in total. There are no appendices. ‘The maximum mark for the examination paper is 60 and the mark obtainable for a question or part of a question is shown in brackets alongside the question, Students to be provided with: The following items of stationery are to be provided: 1 answer book. Instructions to Students: Answer ANY 3 questions. The use of a translation dictionary between English or Welsh and another language, provided that it bears an appropriate school stamp, is permitted in this examination. M2102 1. (a) Explain, with an example, the difference between Third Nor- mal Forin and Boyce-Codd Normal Form. (4) (b) The following table shows some flight booking records: [OID —ONaane Fgh Date From _ ToGo —Expate Fare] CHT Smit —VSeoi—O3704/TA London Pars — 10543 00/07/15 ia Smith BA300 24/09/14 London Florida 12385 2/02/15 $9000 C315 ones onoo/id Cardi! Pans’ 34507 12/02/15 $5.00 cua by/o2"4 tendon Pars MSG? 12/02/15 59.50 ‘C50i_White _BA%0 17/08/14 London _Fleride 56730 22/02/17 _ 68000, © CID = Customer ID © Cllame = Custoner Name FlightNo = Flight Number Date = Date of Flight From = Departing City «To = Arriving City * Cardio = Credit Card Number used to book the flight ExpDate = Card’s Expiry Date Fare = Fare of the flight Using this table, i, identify the functional dependencies that you would expect to hold and express them in @ functional dependency diagram (state any essumptions you make about the data shown in the table); (7 ii, normalise the table into Third Normal Form (primary keys should be underlined); 6) iii, explain in what way your normalised design is better than the given table, ia) vi cMo2102 2. (@) Explain, with an example, what the following statement means. A transaction may be correct in itself, but can still produce a wrong result when it is executed in par- allel with other transactions. COMMIT; (b) Explain in English what each of the following code fragments does: CREATE INDEX ParentKey ON Parent(LastNane) ; DELETE FROM LowStocks WHERE StockWo = 111 AND Quantity < 20; CREATE VIEW ComputingModule AS SELECT + FROM Module WHERE Department = "Computing? WITH CHECK OPTION; SELECT S.S#, $.SName FROM Student $ AND NOT EXISTS (SELECT * FROM Enrolment E WHERE E.Mark < 40 AND E.S# = S.S#); CREATE TABLE Employ (apt char (16) PRIMARY KEY, ae char (18) UNIQUE, Salary Number(6) CHECK (Salary < 100000), Deptt char (16), ‘CONSTRAINT omp_fic FOREIGN KEY (Dept) REFERENCES Department (Dept#) ON DELETE CASCADE); 2] bl a) please turn over 3 (a) () (@) oMo2102 Describe what is meant by indexing and by hashing in the context of database performance optimisation. Consider a file of records whose key values are integers. A B- ‘Tree of order 2 is to be maintained for this file. Records with the following key values are to be inserted into an initially empty file in the order given 2,51, 22, 40, 56, 30, 47, 25, 20, 87, 14, 62, 10, 43, 28, 19, 58, 71, 93 Draw the B-tree as it appears after the insertion of the key value 87 and the B-tree after the final insertion, Given the following query: select count (+) from Student, Enrollment where (Student.Schene = ’Computing? Or Student.Schene = ’Accounting’) And Student. Student i. Explain how a bitmap index may be used to speed up the execution of this query. ii, Explain how a B-tree index may be used to speed up the execution of this query ‘We have not considered B-Trees when duplicate keys are al- Jowed in our course. Can B-trees be used to index such columns, for example, a column containing surnames? Ex- plain your answer. Enrollment .StudentID; \6] 's] 2] Mo2102 4, (a) Briefly explain whet @ Trigger is and give a possible use of trigger in database applications. (b) The following relations form part ofa relational database (the relations are self-explanatory): Patient (Patient_ID, Patient_nane) Doctor (Dector_ID, DoctorName) Drug (Drug_ID,Drug_Nane) Prescription(Doctor_ID, Patient_ID, Drug_ID, Date) Consultation (Patient_ID,Doctor_1D, Date) With reference to this relational schema, write SQL state- ments for the following queries: i. List the names of all drugs which were prescribed on 1 June 2013. ii, List the names of all patients who have been prescribed drug Calpol iii, List the name of patients who had more than one con- sultation with doctors in 2012. iv. List the names of each drug and the number of times it has been prescribed, including those drugs that have not. been prescribed so far. 5X 4] oi io i (a)

You might also like