Practice Midterm Exam - Database System I - Fall 2007 | COMP 6120, Exams of Deductive Database Systems

Material Type: Exam; Class: DATABASE SYSTEMS I; Subject: Computer Sci & Software En; University: Auburn University - Main Campus; Term: Fall 2007;

Typology: Exams

Pre 2010

Uploaded on 02/25/2010

koofers-user-0fl
koofers-user-0fl 🇺🇸

10 documents

1 / 9

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
COMP 5/6120
Database Systems I
Fall 2007
Midterm Exam
Name:
Student ID: _________________
Points Received
Problem 1 20
Problem 2 20
Problem 3 20
Problem 4 10
Problem 5 20
Problem 6 10
Total 100
Exam Rules:
1. Close book and notes, 75 minutes.
2. Please write down your name and student ID number.
3. Please wait until being told to start reading and working on the exam.
Page 1 of 9
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

Download Practice Midterm Exam - Database System I - Fall 2007 | COMP 6120 and more Exams Deductive Database Systems in PDF only on Docsity!

COMP 5/

Database Systems I

Fall 2007

Midterm Exam

Name:

Student ID: _________________

Points Received

Problem 1 20

Problem 2 20

Problem 3 20

Problem 4 10

Problem 5 20

Problem 6 10

Total 100

Exam Rules:

1. Close book and notes, 75 minutes.

2. Please write down your name and student ID number.

3. Please wait until being told to start reading and working on the exam.

Problem 1 Database Concepts (20 points)

(1) Unlike assertions which must be, in principle, checked any time when data is modified, triggers allow users to specify when checking should occur. True False

(2) For any SQL query, there exists a unique translation into relational algebra. True False

(3) In SQL, the value NULL is ignored in any aggregation. True False

(4) In SQL, a view can be used like a stored relation in any operations. True False

(5) The relational data model was proposed by Dr. Edgar Codd in early 1970’s. True False

(6) Schema normalization not only reduces potential data redundancy but also enhances query efficiency. True False

(7) SQL is a declarative query language, in which we simply declare what we want, but not how to compute, in formulating a query. True False

(8) With the five basic operators (selection, projection, union, set-difference, and cross- product), relational algebra can compose most queries. Other operators are just syntactic sugar and can be derived from the basic operations. True False

(9) A natural join is a special case of an equijoin. True False

(10) An aggregation function, e.g., SUM and AVG, returns a value computed from a set of values. Thus, MIN and MAX are not aggregate, since they only return a single value. True False

Problem 3 Relational Algebra (20 points)

Consider the following schema:

Suppliers ( sid: integer, sname: string, address: string) Parts ( pid: integer, pname: string, color: string) Catalog ( sid: integer, pid: integer, cost: real)

The key fields are underlined, and the domain of each field is listed after the field name. Write the following queries in relational algebra.

(1) Find the Supplier names of the suppliers who supply a red part that costs less than 100 dollors and a green part that costs less than 100 dolloars. (5 pts)

(2) Find the pids of the most expensive parts supplied by suppliers named Andy. (5 pts)

(3) Find the pids of parts supplied by at least two different suppliers. (5 pts)

(4) Find pairs of sids such that the supplier with the first sid charges more for some part than the supplier with the second sid. (5 pts)

Problem 5 SQL (20 points)

Consider the relational conceptual database schema used by company Goldfish, Inc. to store information about fish, species and fish tanks (sno is the species number and tno is the tank number):

Fish (fname varchar, fcolor varchar, fweight int, sno int, tno int); Species (sno int, sname varchar, sfood varchar); Tank (tno int, tname varchar, tcolor varchar, tvolume int);

Write SQL statements for the following queries:

(1) Find the names of tanks containing an orange fish heavier than 10 pounds. (5 pts)

(2) Find the names of blue tanks that contain a species that also appears in a green tank. (5 pts)

(3) Find the average fish weight for each species. (5 pts)

(4) Find the average tank volume by species, for those species that appear in two or more tanks. (5 pts)

Problem 6 SQL (10 points)

Consider the following schema

People ( ssn: integer, name: string, phone: string, city: string) Purchase ( buyer-ssn: integer, seller-ssn: integer, store: string, pid: integer) Product ( pid: integer, name: string, price: real, category: string, cid: integer) Company ( cid: integer, name: string, stock-price: real, country: string)

Write the following queries in SQL.

(1) Find the names, stock prices, and countries of companies that have sold products to people living in Auburn but not to people living in Opelika. (5 pts)

(2) Lists the names of all companies that have sold at least two different products (that is, products with different pids ). (5 pts)