Q1) List five responsibilities of a database-management system. Q2) Fill in the terms in the right hand side of the table that match the description from the list below: Instance SQL Integrity constraints Schema Transaction Materializing a view Referential Integrity The grant statement Data Models Data Definition Language (DDL) guard against accidental damage to the database, by ensuring that authorized changes to the database do not result in a loss of data consistency. create a physical table containing all the tuples in the result of some query Unit of work is used to confer authorization Ensures that a value that appears in one relation for a given set of attributes also appears for a certain set of attributes in another relation the logical structure of the database the actual content of the database at a particular point in time A collection of tools for describing: Data, Data relationships, Data semantics and Data constraints Specification notation for defining the database schema widely used non procedural language Q3) how does WAL protocol work? And why? Page 1 of 8
Q4) use this relation to answer a thru e: sid name login age gpa 53666 Jones jones@cs 18 3.4 53688 Smith smith@eecs 18 3.2 53650 Smith smith@math 19 3.8 a. What is the cardinality and Degree of this relation? b. Find names and logins of all 18 year old students? Write the SQL code only. c. Write SQL to find the average of all grades? d. Write SQL to find all stands whose GPA is greater than the average? e. Find all students whose name starts with the letter S? Page 2 of 8
Q5) Giving r and s Relations below answer a thru c a. r x s: b. r s: c. r s: Page 3 of 8
Q6-3.11) Write the following queries in SQL, using the university schema. a. Find the names of all students who have taken at least one Comp. Sci. course; make sure there are no duplicate names in the result. b. Find the IDs and names of all students who have not taken any course offering before Spring 2009. c. For each department, find the maximum salary of instructors in that department. Youmay assume that every department has at least one instructor. d. Find the lowest, across all departments, of the per-department maximum salary computed by the preceding query. Page 4 of 8
Q7-3.12) Write the following queries in SQL, using the university schema. a. Create a new course CS-001, titled Weekly Seminar, with 0 credits. b. Create a section of this course in Autumn 2009, with section id of 1. c. Enroll every student in the Comp. Sci. department in the above section. d. Delete enrollments in the above section where the student s name is Chavez. e. Delete the course CS-001. Page 5 of 8
Q8-3.13) Write SQL DDL corresponding to the schema in the Figure below. Make any reasonable assumptions about data types, and be sure to declare primary and foreign keys. person (driver id, name, address) car (license, model, year) accident (report number, date, location) owns (driver id, license) participated (report number, license, driver id, damage amount) Page 6 of 8
Q9-4.14) Show how to define a view tot credits (year, num credits), giving the total number of credits taken by students in each year. Q10-4.16) Referential-integrity constraints involve exactly two relations. Consider a database that includes the relations shown in Figure below. Suppose that we wish to require that every name that appears in address appears in either salaried worker or hourly worker, but not necessarily in both. a. Propose a syntax for expressing such constraints. b. Discuss the actions that the system must take to enforce a constraint of this form. salaried worker (name, office, phone, salary) hourly worker (name, hourly wage) address (name, street, city) Page 7 of 8
Scheme Diagram from University Database Page 8 of 8