You are on page 1of 9
April 2014 NATIONAL UNIVERSITY OF SINGAPORE SCHOOL OF COMPUTING Examination for ‘Semester 2 AY2013/2014 Time Allowed: 2 Hours (€82102 - DATABASE SYSTEMS INSTRUCTIONS To CANDIDATES 4. This essessment paper contains THREE (3) exercises and comprises NINE (8) prints pages cs2102 2. Students are required to answer ALL questions onthe OCR form or within the spe provided, as nate, 3, This 's 2 Closed Book examination 4. Students are alowed to bring one couble sided page (Ma size) ofhancwrtn noes. 5. Students are allowed to bring a Bingusl dona 6._‘Studonts are alowed tfxing an electronic calulatr, 7. Please write your Matriculation Number Below. MATRICULATION No: is port fr examiners uae only EXERCISE [MARKS | REMARK El (20) OCR Ell (24) Et (16) Total (60) cs2i02 “hiss a sri of mule choice questions (questions 1 o 10) and short essay questons (questions 11018 For each multiple choige question chocss tre best answer snd rept the aresponding chowe onto the OCR {foxm, Each multsle choice questo s worth 2 malts. No marks dodled for wrong answes, areech short essay question ge you answe nthe reserved space Inthe sep, Points maybe deduces {or unmecessary comments ana wrong answers. ‘Exereise |. (20 marks) Mullechotce questons. Answer on the OCR form, ‘Consider the fotowing database schema fora scial nebwerk appaton. sere, name) ‘end ic2) ‘The table ‘user rocorde the ones, and names, nama of use ‘The table Wend records thatthe user wih Has User wh 2" as a end 1 te primary Key of the table user ‘(ste primary Key of the abe nat 1a Inthe tate on retoroncos the table ‘ore "2 inthe able Tend references the table User ‘There are no other constraints, Note thatiendshpis not necessary symmeti,refeve or tansive ‘Question 1. (2 marks) Which of he folowing queries nds the names of users who have no fend? 3) (£X> | 3X1 WY WY (usedX. X) (user, Y) => fend, Y4)). 1B) {546 | at WY WY (sesh, x}. (fendOX, Yt) = auserV3,Y). ©) {2X> | xt ¥¥T WY (use X)a [user VY) w sana, YD 8) Alotihe above. 2) None of he above ‘Question 2 2 marks) Which of he folowing cusses fas the names of users wh have no end”? a) {0X | Xt YYE WY (usenXt, x} userV, ¥) «lend, YN 1) (2K> | axt YE “lunar X) = fendet, YO), 1) ex>| Xt V¥t (usen, 5).nendlet, Y4)} 8) Atotine above 1) None ofthe above ‘Question 3. (2 marks) Wich ofthe folowing statement is coect about the folowing query? $996 [21 VE user, X) = tena, YY 2) finds the names of users who have no tend ) feds the eer of sors whe have ne fend, ©) tis una 9) is sylacteay incomes, ©) None ofthe above. ‘Question 4. (2 marks) Which of he fling statement is corect abou the allowing quay? (0% | BAT WT WY (USOT) 9 (UseRYEY) = endo YA 4) tings me names of users wo have every use a ind 5) nes the Were sore who ae fend to every. ) Its unsae, 9) Its eytactealy incomect, 2) None of the above. sz Let us consider the relation RIA 8, C, 0. E) with he follwing eat Fof functional dependencies. (CD) (8), (C)-> (0), {A.D} -» {0}, B.A) -»(0,C},(B,A.6) + (0,6) Its vied that you study and normalize R wit F before answering the questions ‘Question 6.2 marks) Which ofthe folowing functional dependency is notin F+?| 2) K.O)-10) » >e0) 8) ECD) 4) Alof he above (none of emis nF. 1) None ofthe etove (Bey are alin F+), ‘Question 6. (2 mark) Which ofthe folowing i # completely non trivia funtion dependency in F¥? 8) {A B)-» (0) 5) > 6.0) 2) ADE} (8,c) 9) Alottne stove ©) None ofthe atove ‘Question 7. (2 marks) Which ofthe folowng|s candidate key of ith F? ©) None of the above ‘Question 8. (2 marks) Which of he folowing sa syer key of R with F? @) (A8,c,0), » ABC. 3 EA. 8) Allaine above. 19) None ofthe above. ‘Question 8. (2 marks) Which ofthe flowing isan extended minimal cover of F? 9) (()> (8,0). (A,0} > (},(8,4) > (0). ©) (56.0.8, 14, 0} > (0), (8.4) (on, 8) {(} (0). (A,0. 8} > (Ch 1) Alothe above 2) None ofthe above. ‘Question 10. (2 marks) Which ofthe folowing ea NF lossloss dacompostin of R with F? 8) IMG. BD) R2HA, 6.0) RBA B,C) RAN, A | Ra : 12) None atthe above, cszi02 Exercise (24 marks) Giv your answer.in the apace provided Inthe sip, Pints may be deducted for unnecessary conments, unnecessary long or complested answers and wrong answers Consider te folowing se-ceserbing database schema fr the management of reskfst at Nang-SéDa Resort, tena. sgt nora 296) Sekine. tam) Primary kaye ae underined, ipasepor nthe ase breatastrlerences the primary key of he table customer "em inthe table eaktat eferencos te primary Ke af the aber. ‘The folowing constrains ate enfocad, Customers are Gone bythe pastpert number Noe that two diferent ‘usiomers may have the sare rare. Menu lems ate ried by tha ams (atibuto ta), The combina ‘of trbuts: ate ter and passports usiguo nthe breaks able and none of tr valesis ull The natal Feforontalmagriy apes For exami, Ms. Sinsamu, 235 years old Thal national, wth passport L129, onder ied ce ane coffe on ‘311272018. The next cay, she are ctl ed cea fod tem, whch osts 120 Bont Coflos easing ‘tem, which costs 80 Baht. There another custome, ced Sinsamuk This oer customer Isa 60 years of ‘Amavean natoral, wth passpot UODD% ‘Th flowing is the coresponding excerpt ofthe datsbase stance: customer’Sinsarut, 123%; “Thal, 95) ‘manu(drni Cate’ 50} breokfasiL 125%, 31/212013, Fried Rice’) breakast(L125X" 91/2/2013" “Cofee) breakosi(L125X, 0101/2014" "Caos Consider primary an foreign key constants to sly your answers ‘Question 11. (8 marks) (SL) Find he dferentnatonalties of customer called Sinsamut ‘Question 42. (4 marks) (TRC) Finé the diferent passport numbers of customers who ordered ed oe for bweakfast. cszi02 Reminder: customeriname, aassnat,rstionaiy. £98) rete. a es (Gaspot, date tem ‘Question 13. (4 marks) Exc n Engl, why the flowing SL, query may not correct find he average age ofthe customers who oars rsd ee fr treaktant SELECT AVG(c.592) FROM castors breakfast WHERE: passporsbipassport AND berries Fic ‘Question 14. (4 marks) (SQL) Find the average age of the customers wh ordered fed ric for breaks. csn102 Reminder: customer(name, passin, natonaliy. age) ‘menu(ype. em re). Drefasogespar dal, te) Question 15. (4 marks) (SAL) Find the names of ferent custamers wha ony ordered ofes or toes (or both ‘or none) for beaks! but nothing we. ‘Question 16. (4 marks) (TRC) Find te cheapest fod tem on the menu (he type ofthe tem soo, cs2102 ‘Exercige I (16 marks) Give your answerin the space provided inthe script. Pains may be deducted fr luneceseary comments and wang anor Let us consider th relation with throw atiutos A 8 and C: R= (A,B,C) wth these of funional dopandencies F(ab (ch. Question 17. (marks) Decompose R with F nto BONF (using the algorithm gvonin the lacure i neede. 1 the ‘ecomposlion cepensoncypreeening? Expian and justly tha saps and the soscuion cs2i02 ‘Question 18, (10 marks) Lat us conser the elton R with vee atutes A, B and C: R= (A,B,C). ind two diferent sets F1 and F2 (ferent rom the example set F, iow) of functional dependences such bat In fewtn Ft ang in wit F2, respectively, A and 8 are prime atibutes and Cte not a prime attribute, ‘Te sts F1 and F2 (and F shouldbe minimal noteuivalert, and not equvaint under renaming faut (09 revaming of Aas B andot 8s 4). ng asot 1, give the candidate keys of wih Ft and indeate whether R wih sn 2NF, ONE and BONE Fins a sot 2, give the candidate Kaye of Rwih F? and ingests whether wih F2 sn 2NF. SNF and BONE Forexampl, forR with, Fear (notice that = (}-> (0) e equivalent under the renaming oF 8s 8) “The candidate ey of wih Fare (A.B) (There is ony one cance Koy) ‘Therefore A and 8 are pine atbutes and CIs no Rwineisinaner [YES TNOT7] RwinFisinane? (YES [WOT) Ruin Fisingcnr? (VEST [NOTZ) csni02 Fd a sot 1 such that A and B ae prime attributes and Cis nota prime attribute of R F [The candidate Kays of with FT are Rothe ticinanee [YES TNO) RinFtisinaner — [YESTINOT] Rin tisin pone? [¥ESTTNOT)] Finda s0tF2 such hat A and Bare prime atributes and Cie nt a prime attribute of R F “The candidate tays oR wih F we Roth F2isinanrr (EST TNOT) RwthFisingne? — (YESTTNOT) Roth F2icin Bone? [YES INO] END OF PAPER °

You might also like