You are on page 1of 4
| National University of Computer and Emerging Sciences, Lahore Campus ii iii. iv Course Name: | Fundamentals of Database Systems Course Code: | CS213_ (pun BS Electrical Engineering ‘Semester: Spring2oz1 4 “| Shours 80 {Guy 02-July-2021 70 ALL 4 en : | Final MSA oul. Roll No, WSK Section:_ InstructioniNote Use only black & blue pen to solve the paper. (Question! [Marl 2. Make valid assumptions wherever needed 3._Answer all parts of a question together. 0) CLO4 a, What is meant by physical data independence in case of the three-schema architecture of database management systems? gees Which constraint(s) can be violated by the delete operation? Consider the following relational schema: DEALER (Dealerld, Name, Address, Phone) CAR (Serial No, Model, Manufacturer, Color) SALE (Dealerld, Serial_No, Price) The attributes Dealerld and Serial_No in Sale relation are foreign keys Give relational algebra expressions for the following questions: List the serial_no of cars alongwith the dealer’s name who sold it Find the dealerid(s) of dealer(s) who has sold all cars by manufacturer i ii, Question? [Marks: 20] CLO-2, CLO-3 [PLOS (SLOS.5)| i 1. [CLO2} Consider the relational data model below student department (‘gid “Taname Give appropriate DBMS) to define the database (with all the constraints) this. Host language is separated from SQL by which component of the database management system? Which operation(s) may cause violation of the key constraint in case of a relational data model? “Toyota” QL DDL. statements (in the order you would execute them in real-time on a You decide to add a new column called b_date to the table student. Give the DDL statement to do You want to give a new user access to this database, which SQL command you would use? Which command can be used to permanently save the changes made by updation operations on a relational database? VW. (CLO3] Consider the following tables from an internet movie database. Primary keys are un and the column fid is a foreign key in the table ratings. The ratings are on the scale 1-5, where best and 1 is wor: Ratings Films ; fid Title | yrrelease viewerid fi “at | E fi Title 2016 a E f : g Title2 2018 a canes Yee fad |_ Titles 2018 ett # Titled 2017 x 7 S Titles 2017 vs0 8 coon w Titles 2018 ef Bo eee vio BY] 1-7 vga} 50, 64) a1 wo | 8%] 1 2) (SLOS.5]Write the output of the following query for the database state given above. SELECT films.title, COUNT(rating) FROM films JOIN ratings ON films.fid WHERE yrrelease > 2016 AND rating GROUP BY film.title HAVING COUNT(rating) >= 2 ORDER BY COUNT (rating); ratings.fid Analyze the outputs obtained in part(a) above and comment on what the query is trying to accomplish b) Give SQL queries to retrieve the following (your query must be generic, do not hardeode) st the newest movies ji. Find viewerids who have watched all the movies that viewerid v10 has watched, Question3 (Marks: 20] CLO-4 [PLOS (SLOS.1, 5.2, 5.3)] Agriculture constitutes the backbone of Pakistan's economy. In order to better manage the available agricultural land the provincial government has decided to launch an online system of land records and you have been hired to design a database which would underpin it. Following are the system requirements ¢ The agricultural land is divided into zilla. Each zilla has a unique name and is further sul into tehsils. The name of the tehsil within the zilla is ynique, information regarding the total area within the tehsil (alongwith units) is also kept. Within the tehsil are the agricultural lands (of different area) Information is kept about the private owner(s) of agricultural land and its area (alongwith units) including their name. CNIC number and address. The land could also be owned by the gov: mment, Data is kept about the unit price of land within a tehsil for different years. © Agricultural land is worked upon by farmers. The new system shall keep information regarding the n me, cnic and the daily rate on which the peasant farmers worked on a certain land and during +h farming season (e.g. Rabi 2019, Kharif 2017 etc) wh ck . y \nformation would be tubewell, canal or 1 kept about Nemes the water source inrigatng the land. This water source could be a different farming seas, Water discharge via the source (in cusecs) would also be recorded for ig seasons. River and canal will have a name(ypigue). Information would be kept about i ae ata being taken out of another canal or river. The capacity ofthe potor driving the also need to be kept alongwith the boring depth Data would be kept regarding which crop was cultivated on the land during a certain timeframe. The crop name, (unique), its type (e.g. rabi or kharif) is kept. With this system in place it would be easier to sce if the land is not being exhausted (same crop being cultivated on the same land for consecutive farming seasons). The total yield per unit of land of the crop would be recorded in kgs for each farming season, alongwith its quality and the cost to the farmer for cultivating a land unit. Please analyze the above requirements and draw an EER diagram to cater for the above system stating clearly any assumptions made. Question [Marks: 10] CLO-5 a) Convert the following EER diagram into the corresponding relational model oT Ls ca a > wee L [ess : | SSF pe b) Ina relational data model there are three tables A, B and C. The primary key of B and C ( is the same ag and) refers to the primary key of A. The sum of rows in B and C is always equal to the number of rows in A. Give the EER diagram corresponding to this relational model. gs CO ie oe’ @ 6 & Page 13 of 4 ————————— ram corresponding to it ©) Consider the following relational data model, give the EER diag! — ! description _| afk description anumber Register_val ‘AB->C, A->D} shown below. Aruestions [Marks: 10] CLO-6 SG: i 5 meet i. Given the table R (A, B, C, D) with Functional Dependencies > n What values could be inserted for the missing D and A column values. The domain for D is {d1, d2, 43, d4) and domain for A is {#1, 02, 03, #4) of [da | DC, CD AB, (A, B,C, D), with FDs F = {AB—>CD, CA, A Consider the relational schema X = {AX>Y, YZ, ZX}. Find all the candidate keys for ii, ‘D—+B}. Find a minimal cover of F Given a relation R (A, X, Y, Z) with FDs F R, /Question6 [Marks: 10] CLO-7 [PLOS SLOS.4] simple attribute is already in 2NF if its candidate keys relation R with each column representing satisfy which conditions? Jation R(A, B) is already in BCNF CD.) with FDs {BC ADE, D + B}. The possible keys are {B.C} INF, 2NF, 3NF, or BCNF). Justify your ii, Prove thata iii, Consider the relation R(A, and {CD}. Identify the best normal form that R satisfies ( If the relation is not in BCNF, decompose it until it becomes BCNF. ‘A,B,C,D,E). You do not know the functional answel You are given the relation below for the schema R(. iv, dependencies for this relation Dale pala ave a lowing two relations: R1(A.B,C,D) and R(A.C.E). mposition is not Suppose this relation is decomposed into the fo! Is this decomposition lossless? Explain your answer. What happens when the deco lossless?

You might also like