Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Data vault modeling wikipedia , lookup
Tandem Computers wikipedia , lookup
Microsoft Access wikipedia , lookup
Entity–attribute–value model wikipedia , lookup
Clusterpoint wikipedia , lookup
Versant Object Database wikipedia , lookup
Relational algebra wikipedia , lookup
Open Database Connectivity wikipedia , lookup
Microsoft SQL Server wikipedia , lookup
CSc 460 (Database Design) Module 3 (SQL) Review Fall 2012 1. Show how the following query (on the WebReg schema) can be expressed in the relational algebra with a semi-join. "List the names of buildings in which sections of computer science courses are held." What about an SQL query suggests that it may be mapped to a semijoin? Illustrate with an SQL query for the above expression. 2. Short answer. What construct does each of the keywords in SQL queries correspond to in the tuple relational calculus? For example, "SELECT” corresponds to "{". Give four keywords (other than "SELECT"). 3. Consider the videostore schema on slide R-70 and 71 and the following query. project_Title ( ( (ChildOf EquiJoin_{Parent = Customer.CustomerID} select_{Name="BillSmith"}(Customer) ) EquiJoin_{Child=Rents.CustomerID} Rents ) NaturalJoin Film ) [4] [4] query a. Express this query in SQL. b. Express this query in natural English. (Can you express this in only eight words?) Assume the following cardinalities. ChildOf Customer Rents Film [6] 287 1223 467 8250 c. Provide a lower and an upper bound on the cardinality of the result of your query. Justify your answer. 4. Views are provided in SQL to achieve logical data independence. [6] a. What is the practical utility of logical data independence? Give a concrete example. CSc 460 (Database Design) Module 3 (SQL) Review Fall 2012 [3] b. Express the view, called ForeignFilm, on the video store schema, in SQL, containing the FilmID, RentalPrice, and Title of all foreign films. [3] c. Express this query, using this view, in SQL: "List the names of all customers who have reserved a foreign film". [5] d. Use query modification to translate the query in (c) into a query on the base tables. 5. Map the following SQL query into (normal!) English, relational algebra, and domain relational calculus. SELECT Kind FROM Reserved, Film WHERE Film.FilmID = Reserved.FilmID AND CustomerID = ANY (SELECT CustomerID FROM Customer WHERE ZipCode = 85718) 6. SQL differentiates the notions of database schemas and table schemas. [4] a. Provide one similarity and one difference between these two notions. CSc 460 (Database Design) Module 3 (SQL) Review Fall 2012 [2] b. Provide an SQL statement to define a database schema called Class associated with the user name Rick. [4] c. Differentiate briefly what takes place with the Class schema when it is dropped cascaded versus dropped restricted. 7. The DBMS stores the relational schema as a set of tables. Tables (TableName, Owner) Columns (TableName, ColumnName, DataType, Width) [8] a. Express the following query in relational algebra, tuple relational calculus, domain relational calculus, and SQL. List the columns of data type "INTEGER" in tables owned by Rick. [2] b. Explain precisely why the domain calculus expression is the shortest. [7] c. Express the following query in SQL: List the tables that contain a column for every data type listed in the Columns table. [5] Extra credit. Express this query in the relational algebra. CSc 460 (Database Design) Module 3 (SQL) Review Fall 2012 [6] d. Give an SQL query on this schema that is not possible to express in either relational algebra, domain relational calculus or tuple relational calculus. Explain your reasoning. Also give the English version of your query. Your query should make sense. 8. Expressive power is an important consideration in query language design. [2] a. SQL is relationally complete. Explain what that means. [10] b. Prove that SQL is relationally complete. [5] c. Show that nested selects in the FROM clause do not add any expressive power, by converting the following SQL query into one not using a nested select. SELECT Name FROM Customer, (SELECT * FROM Reserved WHERE ResDate = DATE '1998-10-14') AS R WHERE Customer.CustomerID = R.CustomerID AND Customer.City = 'Tucson' [1] d. Express the above SQL query in colloquial English (not geek-speak). [8] e. Also express this query in relational algebra, relational tuple calculus, and relational domain calculus. CSc 460 (Database Design) [4] Module 3 (SQL) Review Fall 2012 f. Does the MAX aggregate add any expressive power to SQL? Why or why not? 9. Express the following query in tuple relational calculus, tuple domain calculus, relational algebra, and SQL. The query concerns the relations Student(SName, SID), Class(CName, Instructor, Room), and Grade(SID, CName, Grade). List all students who made an A in a class taught by Rick. List the students who made an A in all classes taught by Rick. Which version is the SQL query the most similar to? Which version is the most concise?