Docsity

COSC 3380 Database - Uma, Exams of Computer science

Partial preview of the text

Download COSC 3380 Database - Uma and more Exams Computer science in PDF only on Docsity!

COSC 3380: Design of Database Systems Midterm Exam gg or Student's Nene (KD Student er ~ (1) What are the differences between base relations and virtual relations? Explain with an example each. base rclahons- whe the actal alake al om DH 2 {Q2 nts, - €xampe fudent Jaracs fotter with student jl 77,4 ver at 3 Gotu Hoflow, ¢ sling Divinateny ancl har a * 2 Vurlual Adahem,; not ackally ote clk fo @r I Fi f U the amouat of (Maman (samt wv 4 exaw pl : a pr HES Car get L vpert Are Jiodes b hé ilel not be h hoa ALtOAS (2) How does SQL facilitate implementation of the entity integrity _f constraint and referential integrity constraint in a relational database? Explain with an example. 2 ‘ enhhr ntegerty ergs Uniguns of enthiy: no ob enhhes have the Gime wnfoanandr (nay be fmy Gr Cpe aly prymary ¢ A ? aye rol Stucknts named Harvy Poker muyt have Mitent IDs to f, Ab, Wh dum [ j J ; la honsl betwen -Irfferént prt, male nt ferented infegnty : ensuit (bl Set 1 hr nips betnes ‘ i : y > 4 Sure an tnthly foes not Aeteere a MPN KH } rg enhh @ d . . ve sure to eXcure ple > Grade pfort of Hepp Hermigne 4 to make Saat ANEW) . j hl . aft : } Aovrenga dey {ely meer % a glade W) NO elOng to somé study v KoA nal Perm Any nd / fa $5 WSL. (3) (10 points) 7 ae (i) Explain the difference between a key and a superkey. A tey ty olvayy a, cup ley , dat mob necessary te ofr ory around A Koy hould be wpe loy mh the 004 tumbey of attr bater> (mura malibs) A Super Loy YB & Wmbnaborr ot a number of attthyle hat togelley cekerenint the unqenes of a tuple A et Contauningr a ty comorg otliy attrbules ir a suepr ity . No two hypb» Maw the Same Koy (ii) Why do we designate one of the candidate keys of a relation to be the primary key? : . Cyaventenally we ase ID Wy the princry herawe it han oaly 1 veuliuga (instead of aw combna bon of (ciate of birt, actress, name) Lor eranple). We nod to dederrerns ctignate o Cand date ity fo became we Mad to ine \t fo ung lied iden ty be a Pama Ko y d ote candidate iy’s nowd only be wed to endure Hit cata tatn a wages of fate on pte (S) Sun City Records has decided to store information about musicians who record songs in their studio in a database. Design a relational database schema for Sun City Records (including a diagrammatic representation). The following specification describes the mini-world that your database must model. Be sure to indicate all keys and constraints, and any assumptions you make, ¢ Each musician that records at Sun City has an SSN, a name, an address, and a phone number. SSN uniquely identifies a musician. Each instrument used in songs recorded at Sun City has a unique identification number, a name (eg. guitar, flute) and a musical key (eg. C, B-flat, E-flat). Each song recorded at Sun City has a title and a date. Songs are uniquely identified by a song id. There are two types of musicians recording a song: vocalists and instrumentalists. Each instrumentalist may play several instruments, and a given instrument may be played by several instrumentalists. Each instrumentalist plays at least one musical instrument. Each instrument must be played by some instrumentalist. « Each song is performed by one or more musicians, and a musician may perform a number of songs. e Each musician who performs a song receives a payment. e Each song must be performed by some musician. « Asinger has a type (eg. baritone, tenor, and soprano). « Singers do not play any Instruments. _ The set of singers and the set of instrumentalists are disjoint. 5 $e (25 points) Tv steuapiaest SSN: shar (9) : anume it U5, SSM system Mare: varchar (50): cvsame name cloes not erat 50 Aaractes Adres: Varchay (50) - same Phone rumba, char 40) = assume US Phone vumler M0 courly code T VSTRUMENT,- a int > varchar (15) fabalt be varchar (AO): comme rot excerdiy (0 clanacters PLAY SSN char (D = Same uo unstancatahy’s inst id unt : sare a inshuregts PK (cow, unst—td) Sonaer Sf0y, Name, Adtars , Aire Mentér ; same 09 cntanertalist “ype : Vareharl AS), a7surre Serger fype not tkeeedoy 1S comclas SONG id unt Tle “rebar (40) pale pale deter hype format YIYY- MM~ DD / (b) Provide the list of course names and the prerequisites for each course, SELECT C. Course. 1am, P Course name PROM COURSE ASC, PREREQUISITE AS P, COMBE AS PC WHE 2E Lbewettceucahor — = ©, Course rember AND. oun = PL Louse. rumba)’ / (c) _ Retrieve the names of students who scored an ‘A’ grade. SELECT S Nome | FROM STubent 45 S, Gane REPORT AS G | WHERE $. Stuckat— number. 6. Studint. umber AND G6, Grade = ‘Al ‘ | / Mo Sex [Selary | Super san | Dro | 5 m_ [30000 [333445555 | 5 T__| Wong _| 339445555 | 1955.12.08 638 Voss. Houston TX | M |40000 |agasesss5 | 5 J | Zelaya | 999887777 | 1968.01-19|3921 Castle. Sprng. 1x | F [25000 [987654321 | 4 S| Watace | 967654321 | 1941-06-20 |201 Berry Bellare, ™X | F [49000 |aaacessss | 4 K__ | Narayan | 666884444 | 1962.09.15,| 975 Fire Oak Humbe, TX] M [38000 [333445555 | 5 A_| English | 459453453 | 1972-07-31 | 5631 Rice. Houston, TX | F |25000 [333445555 | 5 V_| Jabbar | 987987987 | 1969-03-29 | 980 Dallas. Houston, TX | M [25000 [987654921 | 4 E | Borg | 888665555 | 1937-11-10 | 450 Stone, Houston, TX | M [55000 |NULL 1 DEPARTMENT DEPT LOCATIONS Dname ‘Onumber Mgr ssn Mgr _start_date Dnumber | Dlocation_ Research 5 333445555 1988-05-22 ‘ Houston Adminintration 4 987654321 1995.01.01 4 Stafford Headquarters 1 888665555 1981-06-19 5 Bellaire 5 Sugarland 5 Houston WORKS ON PROJECT san Pno | Hours Prame Pnumber | Plocation | Dnum |. 123456789 1 325 ProductX 1 Betlawe 5 [123456780 [2 75 Product¥ 2 | Sugartand [| 5 666884448 3 | 400 Product2 3 Houston 5 459459453 1 200 Computenzaton{ 10 | Stafford 4 459459453 2 | 200 Reorganization 20 — | Houston 1 393445556 2 | 100 Newbenefits 300 | Statfora 7 [4 333445555 3 | 100 993445555 10 | 100 DEPENDENT | 393445555 20 | 100 Esen ‘Dependent name | Sex | Bdate Relationship | 999987777 30 | 300 393445655 | Alice F_| 1986-04-05 | Daughter | 999887777 10 | 100 939445555 | Theodore M_| 1983-10-25 | Son | 987987987 10 | 350 333445555 | Joy F | 1958-05-03 | Spouse | 987987087 30 50 987654321 | Abner M | 1942-02-28 | Spouse | 987654321 30 | 200 123456789 | Michael m | 1988-01-04 | Son | 987654921 20 | 150 123456789 | Alice F | 1988-12-30 | Daughter | 988665555 20 | NULL 123456789 | Elizabeth F | 1967-05-05 | Spouse py TN goss w YL Mra anys gy ld - €48s 5965998 beg q nul leg px 40°51 NLIBSERE apne A poy j hop 5 _sSeshuses nas Jil MEY OMI (COS C-49-2yt CHEESES quyug YP | i -90- \96 55559998 srpaibora %G SSSsAnes! OK wy Wb er St 4S -6o- 296) «nnn g7g9y isan) yet | 10- 10> S66) 7264 59496 AB GS S555 nS coon whl ee wo WY feb J -G0-29h = tht 72994 velaRy B yanuez| GSS ERE G rps 4 S65 nse Cay, when 0 $6 G1 -60-2 wl, 8t994 welovon fond wy Bb 92-90-16) [ASI gojon S$ Apmal 4 C49 ERG ous? v A “ptr 4 - Be BSS OG | EMF b SSCA 000% x, 0% 9-10-66 PEPSI 2¢ 4 MMM h 555699893 Oath 4 wh 09 (Bag iba O1-90- ib 2GHSHAG ojn —F Aunt | aa-so-gen forme + ynte * S555 Jy gaetn $3.24 howe 2-40 -1hbi 2s59beb raion Ayu | fi-90- 1961 95599398 vsxopmopeny |, Ine459EM% Ooase d 4.55 WH 1a Wid, bebe gree ohoy32 So omyy | 1o-10-909 tenS9ERG MIR 126459086, ogg, 3 WEN 9M ake 6-10-Ph nie dope fw | ar -So-gcn Ssssnnese S Yoasy /UAS9EPE CONS) 4 4 bok yoo GE 1 10-3%i ponte cr” foamy | bi-ge- ig 58359907 + sothporr 6 5555 9R8 (ion wf, vernal V3" Bp. u-$58i same Me TY oni sho 64S 9U5 heepapony 6 T56909 Gono, W x4 WRENS RS 30.21 96 SSSShMMD Coa 3 mea] eso i, SSNs 5 waa £5 155099 eam Wath B69 21-8) $555 Hh hay NY fi- 90-16 55599 BF spb 5 So9stiner Omog W xp 'aped wPY Ee CO-105%! bashes, yes = uyor | 10-10 G6 164 S9bG 1, “HM hceapes 6 Sass tnsee. Ones ed OPMRE atpeay Ce, E010 5%) be BET! wnt § wyen 22-50 SESSNWES 5 wri 5 sironce, Omit Nyman ice fono-sou Gwgsven ys gO ppv ly Sy wagon] OM, On TE hes ca He) SS] HY "; (c) SELECT * FROM EMPLOYEE, DEPARTMENT; y (5 points) enon Swit —t-nore—~Ssn_goble. Address Sox Sarg Sip Ton Vad Prewne-Pouacror gi, é . (8 pound (d) (SELECT DISTINCT PNumber FROM PROJECTS, DEPARTMENT, EMPLOYEE WHERE DNum=DNumber AND Mgr_SSN=SSN AND FName='James’) UNION ALL (SELECT DISTINCT PNumber FROM PROJECTS, WORKS_ON, EMPLOYEE WHERE PNumber=PNO AND ESSN=SSN AND FName='James’) (Spoints) . Tenuta ao 20