







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
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Main points of this past exam are: Database Schema, Secondary Index, Fixed Length, Bytes Long, Building, Heap Structure, Iterative Substitution, Join Algorithm, Similarities, Two-Phase Locking
Typology: Exams
1 / 13
This page cannot be seen from the preview
Don't miss anything!
College of Engineering Department of EECS, Computer Science Division CS186 Eben Haber Fall 2003 Midterm Midterm Exam: Introduction to Database Systems This exam has seven problems, worth different amounts of points each. Each problem is made up of multiple questions. You should read through the exam quickly and plan your time-management accordingly. Before beginning to answer a question, be sure to read it carefully and to answer all parts of every question!
Good luck!
I. Query Languages (30 points). Given the following database tables, choose all queries in SQL, Relational Algebra or Tuple Relational Calculus that return the proper answer to the corresponding question. Note that each question may have more than one correct answers. Circle all that apply.
Primary keys are underlined. Note that the driver involved in a car accident may not always be the owner of the car. Assume that accident_date is of type integer, and represents a year (e.g. 1980). Year is also of type integer. We assume that a car cannot get involved in more than one accident at a certain date.
Person(SSN, name, address) Car(license, year, model) Accident(license, accident_date, driver, damage_amount) Owns(SSN, license)
D. None of the above
D. None of the above
D. None of the above
B. SELECT O.SSN, P.address, (SELECT MIN(damage_amount) FROM Accident) FROM Owns O, Person P, Accident A WHERE O.SSN=P.SSN AND A.license=O.license
C. SELECT O.SSN, P.address, A.damage_amount FROM Owns O, Person P, Accident A WHERE O.SSN=P.SSN AND A.damage_amount=(SELECT MIN(damage_amount) FROM Accident) D. None of the above.
B. SELECT DISTINCT A1.license FROM Accident A WHERE A1.license IN (SELECT A2.license FROM Accident A WHERE A1.accident_date<>A2.accident_date) C. SELECT license FROM Accident GROUP BY license HAVING COUNT(accident_date)> D. None of the above
II. External Sorting (10 points)
IV Query Optimization
Consider the following schema
Sailors(sid, sname, rating, age) Reserves(sid, did, day) Boats(bid, bname, size)
Reserves.sid is a foreign key to Sailors and Reserves.bid is a foreign key to Boats.bid.
We are given the following information about the database: Reserves contains 10,000 records with 40 records per page. Sailors contains 1000 records with 20 records per page. Boats contains 100 records with 10 records per page. There are 50 values for Reserves.bid. There are 10 values for Sailors.rating (1...10) There are 10 values for Boat.size There are 500 values for Reserves.day
Consider the following query
SELECT S.sid, S.sname, B.bname FROM Sailors S, Reserves R, Boats B WHERE S.sid = R.sid AND R.bid = B.bid AND B.size > 5 AND R.day = 'July 4, 2003';
(a) Assuming uniform distribution of values and column independence, estimate the number of tuples returned by this query.
Consider the following query
SELECT S.sid, S.sname, B.bname FROM Sailors S, Reserves R, Boats B WHERE S.sid = R.sid AND R.bid = B.bid (b) Draw all possible left-deep query plans for this query:
(c) For the first join in each query plan (the one at the bottom of the tree, what join algorithm would work best? Assume that you have 50 pages of memory. There are no indexes, so indexed nested loops is not an option.
VI. Functional Dependencies and Normalization (20 points total) Consider the attributes A B C D E F G which have the following functional dependencies: AD à F AE à G DF à BC E à C G à E
VII. Entity-Relational Model (20 Points) a) (10 points) Draw an E-R diagram for the following situation:
b) (10 points) Using SQL, convert the following ER diagram to the relational model. Hint: You do not need CHECK constraints.