TEST 1 CSCE 520 – Spring 2011 Name: Major: SSN (last 4 digits): Q1 (30) Q2 (20) Q3 (15) Q4 (15) Q5 (20) Bonus (5) Q6 (20) – Grad. only Total Answer the following questions. Be brief and precise. You have 1 hour 15 minutes to finish the test. Undergraduate students must answer questions 1,…, 5; graduate students must answer additional question 6 for full credit. The bonus question is open for everyone. 1. You are asked to design a database system for a health club. The database would contain data about customers, their training, contact numbers, etc. Show the main steps you would perform for designing and implementing the database. (Don’t show the actual schemas!) Multiple good answers may exist. Justify your reasoning. 2. Consider the relation schema: Ship(class, type, country, numGuns, bore, displacement) Write the relational algebra expression to ensure that no class of ships may have guns with larger than 16-inch bore. bore>16 (Ship) = How can you enforce the same constraints using SQL? During CREATE TABLE statement: CREATE TABLE Ship ( … Bore INT CHECK (Bore <=16) ); 3. Describe the characteristics of relations that make them different from ordinary tables and files. Multiple characteristics exist, such as: Structure Granularity and efficiency of data access Semantics of stored data Support for consistency and persistent storage Support for concurrency Etc. 1 4. Describe the difference between natural join and theta-join when the condition of the theta join is to equate the attributes appearing in the schemas of both relations. Describe the schema, number of tuples, and control of join operation. Schema Number of Tuples Control of join Natural join All attributes of the relations With single occurrence of the Overlapping attributes Theta-join All attributes of the relations with multiple occurrence of the overlapping attributes Joins only those tuples that have the same values for overlapping Attributes Automatically for shared attributes joins all tuples and chooses those that satisfy the selection cond. Cartasian product 5. Why is it important to have ACID properties of transactions? Without ACID properties, we cannot guarantee transaction correctness. Show an example, when the violation of one or more of the ACID properties would create an incorrect transaction execution. Multiple examples exist, for example, only ½ of a transaction is executed, or incorrect execution, e.g., allow for bank account to have negative balance, etc. 6. What is the difference between the SELECT operator () in relational algebra and the SELECT keyword in SQL? Both projects the selected attributes. The main difference is the works on sets, and the output is a set, while SQL SELECT is a bag. That is if the answer has more than one occurrences of the same tuple, will return only one of them, while SQL SELECT will return all. We can eliminate the duplicates of the SQL SELECT by using the “SELECT DISTINCT” command. Assume that R(A,B) and S(B,C) are relations. Convert the following relational algebra expression to a corresponding SQL statement: AB (C=3(R |X| S) (|X| is the natural join) SELECT A, R.B FROM R, S WHERE R.B = S.B AND C= 3 ; 2