









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Exam; Professor: Sinha; Class: Database Systems; Subject: Computer Science; University: University of Illinois - Urbana-Champaign; Term: Fall 2010;
Typology: Exams
1 / 16
This page cannot be seen from the preview
Don't miss anything!










It is possible that two entity sets are connected to each other by more than one relationship. Keep this kind of possibility in mind as you answer this question.
You have been asked to design a database about a university:
(a) Draw an ER diagram for this application. Be sure to mark the multiplicity of each relationship of the diagram. Decide the key attributes and identify them on the diagram. Please state all assumptions you make in your answers. (8 points)
(b) Translate your ER diagram into a relational schema, following the methodology discussed in class. Merge relations where appropriate. Specify the key of each relation in your schema. ( 8 points)
The following database schema consists of three relations, whose schemas are:
Product(model, maker, type), PC(model, speed, ram, hd, pc − price), Printer(model, color, choice, printer − price),
The Product relations gives the manufacturer, model number and type (PC or printer) of various products. We assume for convenience that model numbers are unique over all manufacturers and product types. The PC relation gives for each model number that is a PC the speed (of the processor, in gigahertz), the amount of RAM (in megabytes), the size of the hard disk (in gigabytes), and the price. The Printer relation records for each printer model whether the printer produces color output (true for color, false for black-white), the process choice (laser or ink-jet, typically), and the price.
A sample instance of this schema is shown below:
Product Relation model maker type 1001 HP pc 1002 HP pc 1003 Dell pc 1004 Dell pc 1005 Dell pc 1006 Acer pc 1007 Sony pc 1008 Sony pc 1009 Fujitsu pc 2001 Dell printer 2002 Dell printer 2003 Canon printer 2004 Canon printer 2005 HP printer 2006 Sony printer
PC Relation model speed ram hd pc-price 1001 2.66 1024 250 2114 1002 2.10 512 250 995 1003 1.42 512 80 478 1004 2.80 1024 250 649 1005 3.20 512 250 630 1006 3.20 1024 320 1049 1007 2.20 1024 200 510 1008 2.20 2048 250 770 1009 2.00 1024 250 650
Printer Relation model color choice printer-price 2001 true ink-jet 99 2002 false laser 239 2003 true laser 899 2004 true ink-jet 120 2005 false laser 120 2006 true ink-jet 100
Answer the following queries using expressions of relational algebra. Your queries should work for any instance of the database, not just this one.
(a) List all the makers who make PC with a hard disk of at least 200GB. (4 points)
(b) List all the makers who sell only one type of products (either PC or printer, not both). ( 7 points)
(c) List all the makers who sell at least two different models of PC (6 points)
Solution:
(b) Translate your ER diagram into a relational schema, following the methodology discussed in class. Merge relations where appropriate. Specify the key of each relation in your schema. ( 8 points)
Solution: If we do not merge relations at all, we get: Professor(SSN, name, rank) Project(pid, s date, e date) Department(DeptNO, name, office) WorkOn(SSN, pid) Manages(SSN, pid) WorksIn(SSN, DeptNO) Runs(SSN, DeptNO)
But, we could combine the Project relation with the Manages relation, and the Department rela- tionwith the Runs relation: Professor(SSN, name, rank) Project(pid, SSN, s date, e date) Department(DeptNO, SSN, name, office) WorkOn(SSN, pid) WorksIn(SSN, DeptNO)
Consider a relation R(A,B,C,D,E), with FDs AB → C, C → A, C → BD, D → E
(a) List all the keys of R. Do not list superkeys which are not (minimal) keys. (6 points)
Solution: AB, C
(b) Is this relation in BCNF? If you answer is yes, explain why it is. If you answer is no, decompose the relation into BCNF, showing your decomposition steps. (10 points)
Solution: No. The last FD, D → E, violates BCNF. We decompose into R1(DE) and R2(ABCD). R1 is in BCNF because the only relevant FD, D → E, does not violate BCNF (and because its a two-attribute relation). R2 has the relevant FDs AB → C, C → A, C → B, C → D, none of which violate BCNF. Therefore we are done.
NetID:
(a) select model, maker, speed from Product, PC where Product.model = PC.model and pc.price > 800. (4 points)
Solution: model maker speed 1001 HP 2. 1002 HP 2. 1006 Acer 3.
(b) List all the makers who make either laser printers or 1024M-RAM PCs(can be both). ( 6 points) Solution: (select maker from Product, PC where Product.model = PC.model and ram = 1024 ) union (select maker from Product, Printer where Product.model = Printer.model and choice = ’laser”)
(c) List all the model numbers of printers whose price are higher than any existing PC. (6 points) select model from Printer where printer-price > ALL (select pc-price from PC)