






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
The second exam for the cs186 course on introduction to database systems offered by the university of california in spring 2008. The exam covers sql query processing, functional dependencies, normalization, and physical design. It includes four sections with a total of 60 points, each addressing different concepts and techniques in database systems.
Typology: Exams
1 / 10
This page cannot be seen from the preview
Don't miss anything!
Class Account: ___________________________ UNIVERSITY OF CALIFORNIA Department of EECS, Computer Science Division CS186 Bohannon/Cooper Spring 2008 Second Exam: Introduction to Database Systems April 15, 2008 Instructions:
a. Write a SQL query to find the issue number of all comic books with title “Superman” that “Superwoman” appears in. b. Write a SQL query to find, for each character who appears in comic books with title “Batman” or “Dark Knight”, how many times they appeared altogether in those comic books.
2. Query processing (1 8 points) Consider the following schema: LibraryBooks(ISBN, Title, Author, Branch) Patrons(CardNumber, Name, Address, City, State, ZipCode) CheckedOut(CardNumber, ISBN, DueDate) a. The DBMS optimizer is considering two plans for the following query: SELECT Title, Author, Name FROM LibraryBooks, Patrons, CheckedOut WHERE LibraryBooks.ISBN = CheckedOut.ISBN AND Patrons.CardNumber = CheckedOut.CardNumber AND Branch=’Central’ AND DueDate>Now; Assume “Now” is a special value that always evaluates to, well, now. The two plans are: LibraryBooks CheckedOut Patrons NestedLoopJoin NestedLoopJoin Selection (DueDate>Now) Projection(Title,Author,Name) Selection (Branch=Central) Plan A LibraryBooks CheckedOut Patrons NestedLoopJoin NestedLoopJoin Selection (DueDate>Now) Projection(Title,Author,Name) Selection (Branch=Central) Plan B
a.1 Assuming you have no statistics and know nothing about the contents of each relation, which plan is likely to cost less? Why? a.2 Assume now that you have the following statistics:
3. Functional dependencies and normalization ( 12 points) a. Consider a relation with the following schema and functional dependencies: Tests(PatientID, DoctorID, TestDate, Type, Lab, Technician, Fee, ResultDate, Status); PatientID, DoctorID → TestDate PatientID, TestDate, Type → Lab Technician → Lab Type → Fee PatientID, TestDate, Type → ResultDate, Status a.1 Is this relation in BCNF? Why or why not? b. Consider a relation with the following schema and functional dependencies: AstronomicalObjects(MessierNumber, CommonName, Coordinates, Type, Distance, Galaxy) MessierNumber → CommonName CommonName → Coordinates, Type MessierNumber → Distance CommonName → MessierNumber, Galaxy b.1 What are the candidate keys for this relation? Also, give at least one superkey.
b.2 Is this relation in BCNF? Is it in 3NF? Why or why not? c. Consider a relation with the following schema and functional dependencies: Recipes(Title, Genre, PreparationTime, Author, EstimatedCost) Title → Genre Title, Author → PreparationTime, EstimatedCost c.1 Which attributes of the relation are prime? Why? c.2 Is the relation in 3NF? Why or why not?
a. If we only create one index for UserProfiles, what should the index be on? Why? Should it be clustering? b. Should we create an index for Posts? If so, what attribute or attributes should it be on? If multiple attributes, what order should they be in? If we should not create an index, why not?
5. Transactions ( 5 points) An ACID transaction would permit the following situations (mark True or False for each): a. _____ After a failure, an uncommitted transaction is rolled back and all of its effects are erased. b. _____ After a failure, a committed transaction is rolled back and all of its effects are erased. c. _____ Two transactions update the same tuple and then commit, and the effects of both transactions are visible afterwards. d. _____ An unserializable schedule is executed. e. _____ A transaction reads the same tuple twice without writing it in between and sees two different values.