9 Pages

Exam2Sol

Course: COP 5725, Spring 2012
School: University of Florida
Rating:
 
 
 
 
 

Word Count: 1169

Document Preview

Management Database Systems (COP 5725) (Spring 2012) Instructor Dr. Markus Schneider TA Nam Nguyen Exam 2 Solutions Name: UFID: Email Address: Pledge (Must be signed according to UF Honor Code) On my honor, I have neither given nor received unauthorized aid in doing this assignment. _______________________________________________ Signature For scoring use only: Question 1 Question 2 Question 3 Question 4...

Register Now

Unformatted Document Excerpt

Coursehero >> Florida >> University of Florida >> COP 5725

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
Management Database Systems (COP 5725) (Spring 2012) Instructor Dr. Markus Schneider TA Nam Nguyen Exam 2 Solutions Name: UFID: Email Address: Pledge (Must be signed according to UF Honor Code) On my honor, I have neither given nor received unauthorized aid in doing this assignment. _______________________________________________ Signature For scoring use only: Question 1 Question 2 Question 3 Question 4 Total Maximum 20 25 35 20 100 1 Received Question 1 (SQL and Relational Algebra) [20 points] (a) Let R(A:D1, B:D2, E:D3) and S(C:D1, H:D4) be two table schemas in which A, B, C, E, and H are attributes, D1, D2, D3, and D4 are data types, and F is a condition. Provide equivalent (standard) Relational Algebra expressions for the following two SQL queries. 1. [5 points] SELECT DISTINCT A FROM R WHERE A IN (SELECT DISTINCT C FROM S WHERE F) Solution: The only Relational Algebra operator that allows us to bring two tables in relationship to each other is the Cartesian Product operator. An equivalent Relational Algebra expression is: A(A=C(R F(S))) 2. [8 points] SELECT DISTINCT A FROM R WHERE A > ALL(SELECT C FROM S WHERE F) Solution: The strategy is to form a Cartesian Product between the A-Values in R and the selected C-values in S and then to select those tuples of the Cartesian Product for which A C holds. We then project on A. This means that we get all A-values from R that are less or equal to some C-value from S. A-values from R that are larger than all C-values from S are not part of the intermediate result. To get them we subtract the intermediate result from the projection of R on A. We obtain: A(R) A(AC(A(R) C(F(S)))) (b) [7 points] The Cartesian Product is one of the five basic Relational Algebra operators. The Division (Quotient) operator is a derived relational algebra operator. It is considered to be the most challenging of all Relational Algebra operators. Is the statement The Division operator is the opposite of the Cartesian Product operator correct or incorrect? Please argue in either direction. Solution: The statement is correct. Consider the following tables R, S, and T given as 2 Obviously, T = R S holds. All tuples of R are concatenated with all tuples of S. Therefore, we obtain 3 Question 2 (QBE) [25 points] Consider the following relational schemas of the COMPANY database: EMPLOYEE (SSN, Name, Bdate, Address, Salary, DeptId) DEPARTMENT (DeptId, Dname, Office, Mng-SSN) PROJECT (Code, Name, Budget, DeptId) JOIN (ESSN, PCode, StartDate) EMP-DEPENDENT (ESSN, Dependent-Name, Bdate, Relationship) (1) Find the social security numbers of employees who have joined project number 3 or project number 4. [3 points] JOIN ESSN PCode StartDate P._x 3 P._y 4 (2) Find the social security numbers of employees who take part in both project number 3 and project number 4. [4 points] JOIN ESSN PCode StartDate P._x 3 _x 4 (3) Find the names of the employees who do not join any project. [4 points] EMPLOYEE SSN Name Bdate Address Salary DeptId _y P. JOIN ESSN PCode StartDate _y (4) Find the employees name, dependents name and their relationship for all the employees in department number 1. Show the result in a user-defined relation. [5 points] EMPLOYEE SSN Name Bdate Address Salary DeptId _x _y EMP-DEPENDENT 1 ESSN Dependent-Name Bdate Relationship _x _z _t RESULTS Name Dependent-Name Relationship P. _y _z _t 4 (5) List SSN, Name, Bdate of all employees in department number 1. Order the list first by the values of the attribute Name in ascending order then by the values of the attribute Bdate in descending [4 order. points] EMPLOYEE SSN Name Bdate Address Salary DeptId P._x P.AO(1)._y P.DO(2)._z 1 (6) Find the names of the employees who join every project. [5 points] EMPLOYEE SSN Name Bdate Address Salary DeptId _y P. JOIN ESSN PCode G._y StartDate CNT.UNQ._z PROJECT Code Name Budget DeptId _x CONDITIONS CNT.UNQ._z = CNT.UNQ._x 5 Question 3 (SQL) [35 Points] Consider the following schema: Movie (movieID, director_PersonID, name, budget, gross, runtime, year) Person (personID, name, yearofBirth) Acts (personID, movieID, salary) Write SQL queries for the following questions. [7 points each] (a) Find the movies that are directed by Krzysztof Kieslowski and have positive revenue. (b) Find the names of the directors who have directed more short films (<60 minutes) than full length movies (60 minutes). (c) Find the movies which have spent less than 50% of their budget for their actors and actresses. (d) Find the movies with their directors who also act in that movie. (e) Find the movies which were directed by the oldest directors at the time a movie was shot. Solution: (a) select m.Name from Movie as m, Person as p where p.Name=' Krzysztof Kieslowski' and p.PersonID=m.Director_PersonID and m.Gross>m.Budget (b) select from where T1.pname (select p.PersonID as personid, p.Name as pname, count(m.MovieID) as no_short_movies from Movie as m, Person as p where m.Runtime<60 and m.Director_PersonID=p.PersonID group by p.PersonID, p.Name) as T1, (select p.PersonID as personid, count(m.MovieID) as no_long_movies from Movie as m, Person as p where m.Runtime>=60 and m.Director_PersonID=p.PersonID group by p.PersonID) as T2 T1.personid = T2.personid and T1.no_short_movies>T2.no_long_movies 6 (c) select Name from Movie, (select MovieID, sum(Salary) as SumActorsSal from Acts group by MovieID) as SalPerMovie where Movie.MovieID=SalPerMovie.MovieID and SumActorsSal<0.5*Budget (d) select distinct (m.Name, p.Name) from Movie as m, Person as p, Acts as a where m.MovieId=a.MovieId and a.PersonId=p.PersonId and p.PersonId =m.Director_PersonID (e) select m.Name from Movie as m, Person as p where m.Director_PersonID=p.PersonID m.year-p.YearofBirth = (select from where and max(year-YearofBirth) Movie, Person Director_PersonID=PersonID) 7 Question 4 (Relational Algebra and SQL) [20 Points] Consider the following relational schemas: Employee (person_name, street,city) Company (company_name, city) Works (person_name, company_name, salary) Manages (person_name, manager_name) Write the following queries in Relational Algebra and SQL. 1. Find the names of all managers who earn more than $10,000. [4 points] select distinct w.person_name from works w, manages m where w.person_name=m.manager_name and w.salary>10000 2. Find the names of employees who work for some company in Boston. [4 points] " " select distinct w.person_name from works w, company c where w.company_name=c.company_name and c.city=Boston 3. Find the streets of employees who work for all companies in Boston. [8 points] select from where and , " " distinct e.street employee e, works w e.person_name=w.person_name not exists (( select company_name from company where city=Boston) except (select company_name from works w1 where w1.person_name=w.person_name)) 8 4. Find the names of managers who manage all employees working for Company A. [4 points] , "A" select m.manager_name from manages m where not exists((select person_name from works where company_name=A) except (select m2.person_name from manages m2 where m.manager_name=m2.manager_name)) 9
Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

University of Florida - COP - 5725
Database Management Systems (COP 5725)(Spring 2012)Instructor: Dr. Markus SchneiderTA: Nam NguyenHomework 2 SolutionsNameUFIDEmail AddressPledge (Must be signed according to UF Honor Code)On my honor, I have neither given nor received unauthorize
University of Florida - COP - 5725
Database Management Systems (COP 5725)(Spring 2012)Instructor: Dr. Markus SchneiderTA: Nam NguyenHomework 3NameUF IdEmail AddressPledge (Must be signed according to UF Honor Code)On my honor, I have neither given nor received unauthorized aid in
University of Florida - COP - 5725
Database Management Systems (COP 5725)(Spring 2012)Instructor: Dr. Markus SchneiderTA: Nam NguyenHomework 3 SolutionsNameUF IdEmail AddressPledge (Must be signed according to UF Honor Code)On my honor, I have neither given nor received unauthoriz
University of Florida - COP - 5725
Database Management Systems (COP 5725)(Spring 2012)Instructor: Dr. Markus SchneiderTA: Nam NguyenHomework 4NameUF IdEmail AddressPledge (Must be signed according to UF Honor Code)On my honor, I have neither given nor received unauthorized aid in
University of Florida - COP - 5725
Database Management Systems (COP 5725)(Spring 2012)Instructor: Dr. Markus SchneiderTA: Nam NguyenHomework 4 SolutionsNameUF IdEmail AddressPledge (Must be signed according to UF Honor Code)On my honor, I have neither given nor received unauthoriz
University of Florida - COP - 5725
Database Management Systems (COP 5725)(Spring 2012)Instructor:Dr. Markus SchneiderTA:Nam NguyenHomework 5Name:UFID:Email Address:Pledge (Must be signed according to UF Honor Code)On my honor, I have neither given nor received unauthorized aid i
University of Florida - COP - 5725
What you should have learned after this lecture . what aggregation functions are grouping in SQLdistinction between upper and lower caseString patterns in SQL are expressed with the aid of the like operator.example: Find all students with names Meier
University of Florida - COP - 5725
What you should have learned after this lecture . sorting in SQL what nested queries are how different kinds of joins can be explicitly expressedexamples (relation lectures extended by the attribute hpw (hours per week) Determine the number of hours
University of Florida - COP - 5725
What you should have learned after this lecture . how to determine whether a given FD is contained in the closure of a set of FDs what a canonical cover of a set of functional dependencies is how a canonical cover is computedContainment of a FD in a c
University of Florida - COP - 5725
What you should have learned after this lecture . what normalization means and how it is done what the benefits and the drawbacks of the normalization process are what the normal forms aredependency preservation goal: All FDs that hold for schema R a
University of Florida - COP - 5725
What you should have learned after this lecture .what the normal forms are The following anomalies can occur:+ insertion anomaly: What do we do with students who do not attend a lecture?+ update anomaly: If a student reaches the next semester, we must
University of Florida - COP - 5725
What you should have learned after this lecture .what the normal forms arefundamentals of database application programmingstep 1: computation of a canonical cover (precomputed) FD 1:cfw_pers-id cfw_name, rank, room, city, street, state FD 2:cfw_roo
University of Florida - COP - 5725
What you should have learned after this lecture .fundamentals of database application programmingPL/SQLexample:/ Creation of a new object of class StatementStatement stmt = con.createStatement();/ Translation of the query and creation of a new objec
University of Florida - COP - 5725
What you should have learned after this lecture . PL/SQL what data integrity means how integrity constraints are expressed in SQL PL/SQL also supports the definition of recordstype person_type is record (name varchar(50), salary int);variable declar
University of Florida - COP - 5725
What you should have learned after this lecture . How integrity constraints are expressed in QBE Why (purely) relational database systems are not sufficient any more What object-relational database systems (ORDBS) are What the benefits of ORDBS are9.
University of Florida - COP - 5725
What you should have learned after this lecture . further concepts of object-relational database systems (ORDBS) what query processing isinsert into company values(XYZ, array[Mall Avenue, Sales Street, Sellers Drive]);Alternatively:insert into compa
University of Florida - COP - 5725
What you should have learned after this lecture .how algebraic optimization is done10.2 Phases of translation/optimizationgoal: syntactical and semantical analysis of the querygiven: query in a relational query language, e.g. SQLstep 1: translation o
University of Florida - COP - 5725
What you should have learned after this lecture .how algebraic optimization is donerule 8: permutation of a selection with a join or a cross product, if it only usesattributes of one of the two operand relations. cfw_ , : F(R1 R2) = F(R1) R2(attr(F)
University of Florida - COP - 5725
10.4 Physical Optimization(We here deal only with some few aspects. This theme is especially a topic of a courseImplementation of Database Systems.)Introduction The physical algebra operators realize/implement the logical operators. A logicaloperator
University of Florida - COP - 3530
cop3530sp12Parameter passingcall by value- appropriate for small objects that should not be altered by the functioncall by constant reference- appropriate for large objects that should not bealtered by the functioncall by reference -appropriate for a
University of Florida - COP - 3530
COP 3530Data Structures &amp; AlgorithmsDiscussion Session 3OutlineInput-output streams in C+Floating point precisionFile manipulationPointers in CVector class in C+Strings in C and C+About meEyup Serdar Ayazayaz@cise.ufl.eduTA Office: E309This
University of Florida - COP - 3530
Copyright 2003 Pearson Education, Inc.Slide 1Chapter 11Strings and VectorsCreated by David Mann, North Idaho CollegeCopyright 2003 Pearson Education, Inc.Slide 2OverviewAn Array Type for Strings (11.1)The Standard string class (11.2)Vectors(11.3
University of Florida - EEL - 4712
University of Florida - EEL - 4712
University of Florida - EEL - 4712
EEL 4712Midterm 2 Spring 2011VERSION 1Name:UFID:Sign your name here if you would like for your test to be returned in class:_IMPORTANT: Please be neat and write (or draw) carefully. If we cannot read it with areasonable effort, it is assumed wron
University of Florida - EEL - 4712
EEL4712Name: Midterm1Spring2012VERSION1UFID: IMPORTANT: Please be neat and write (or draw) carefully. If we cannot read it with areasonable effort, it is assumed wrong. As always, the best answer gets the most points.COVERSHEET:Problem#: Points
University of Florida - EEL - 4712
EEL4712Name: Midterm2Spring2012VERSION1UFID: Signyournamehereifyouwouldlikeforyourtesttobereturnedinclass:_IMPORTANT: Please be neat and write (or draw) carefully. If we cannot read it with areasonable effort, it is assumed wrong. As always, the
University of Florida - EEL - 4712
University of Florida - EEL - 3396
Book sections to be covered in EEL 3396 Spring 2012 during (tentatively):Week 1: Ch 1 superficially, 2.3W2: 2.5 ,3.1.allW3: 3.2. all except 3.2.5W4: 3.3 allW5: 3.4 all, 3.5W6: 4.1, 4.2, 4.3W7: 4.4, except 4.4.5W8: 5.1 superficially, 5.2, 5.3W9: 5
University of Florida - EEL - 3396
Home work assignments in preparation for the weekly Wednesday 10 minute quizzes.Note that you can only work the quiz problem successfully if you have studied theseassignments. Quizzes will be closed book, no notes. Physical constants will be given.The
University of Florida - EEL - 3396
Home work assignments in preparation for the weekly Wednesday 10 minute quizzes.Note that you can only work the quiz problem successfully if you have studied theseassignments. Quizzes will be closed book, no notes. Physical constants will be given.Brin
University of Florida - EEL - 3396
Home work assignments in preparation for the weekly Wednesday 10 minute quizzes.Note that you can only work the quiz problem successfully if you have studied theseassignments. Quizzes will be closed book, no notes. Physical constants will be given.Brin
University of Florida - EEL - 3396
Course Number and TitleEEE 3396- Solid State Electron Devices1. Catalog Description (3 hrs) Introduction to the principles of semiconductorelectron device operation.2. Pre-requisites and Co-requisites EEL 3111 - Circuits I3. Course Objectives: To pre
University of Florida - EEL - 3396
University of Florida - EEL - 3396
University of Florida - EEL - 3396
University of Florida - EEL - 3396
University of Florida - EEL - 3396
University of Florida - EEL - 3396
University of Florida - EEL - 3396
University of Florida - EEL - 3396
University of Florida - EEL - 3396
University of Florida - EEL - 3396
Purdue - AAE - 340
Purdue - AAE - 340
C1Moment / Angular MomentumOperate on Law of Motion to obtain relationship between moment andrate of change of angular momentuma pivotal equation inrotational dynamicsDerivationiid r opvdtpiid iv pAdtLaw of Motion:F m iApOperate onthe
Purdue - AAE - 340
D1Integrals of the MotionI. Work and EnergyOperate on Law of MotioniFv m ApiipiipdvmdtiiFvpd1 imvdt 2vpivppivpkinetic energy TiiFdTvTdtpAnother form of Law ofMotionyields one scalardifferential equationIntegr
Purdue - AAE - 340
M1Rigid Bodies Angular MomentumlLaws of Motion:F M i Acmar Momentumid iH qM M qcm i AqdtqDefinitionsnM q j Fjqj 1nidqjH mjdtj 1qiqjDifficulty with applying this to systems of particles: to calculate Hrequires and d dt for every
Purdue - AAE - 340
O1Examplel ircular disk welded to a &quot;massless&quot; shaft.CShaft rotates freely in frictionless bearings at A and B.(Disk remains in a vertical plane.)Point O offset from cm by distance h.arMomentum(1)(2)(3)(4)gDerive EOMDetermine bearing react
Purdue - AAE - 340
AAE 340 Dynamics and VibrationsProblem Set 8Due: 3/9/12Problem 1: The system below consists of two particles of mass m and 2m. They areconnected by a rigid, massless rod of length L; the rod has a pivot point at C. The pivot isconstrained to move ver
Purdue - AAE - 340
AAE 340 Dynamics and VibrationsProblem Sets Format for SubmissionSubmit a professional looking document; include the following elements:1. Statement of the problem in the formGiven:Find:This is not necessarily just repeating the problem statement. R
Purdue - AAE - 340
Purdue - AAE - 340
Purdue - AAE - 340
01316 8924 1 2 7 3 449 72 6 8929 3 3 7 3 92 989 027 3 9
Purdue - AAE - 340
Purdue - AAE - 340
Purdue - AAE - 340
Purdue - AAE - 340
Purdue - AAE - 340
Purdue - AAE - 340
Purdue - AAE - 340
Purdue - AAE - 340