Docsity

Midterm Practice Questions - Database Design | CMSC 424, Exams of Principles of Database Management

Toggle sidebar
bg1
1
UNIVERSITY OF MARYLAND
Department of Computer Science
CMSC424 Database Design
Roussopoulos
MIDTERM
CLOSED BOOK
Numbers in square brackets indicate points.
You should have 10 non-blank pages (including this cover)
Weight: 22% of the course grade
QUESTION POINTS OUT OF
Misc Questions 5
E-R Modeling 3
Functional Dependencies 7
Relational Algebra 3
SQL 4
TOTAL 22
pf3
pf4
pf5

Partial preview of the text

Download Midterm Practice Questions - Database Design | CMSC 424 and more Exams Principles of Database Management in PDF only on Docsity!

UNIVERSITY OF MARYLAND

Department of Computer Science

CMSC424 Database Design

Roussopoulos

MIDTERM

CLOSED BOOK

Numbers in square brackets indicate points.

You should have 10 non-blank pages (including this cover)

Weight: 22% of the course grade

QUESTION POINTS OUT OF

Misc Questions 5

E-R Modeling 3

Functional Dependencies 7

Relational Algebra 3

SQL 4

TOTAL 22

1. Misc Questions [5]

Each question below is worth half a point.

a) Specify two of the problems caused by data redundancy.

b) What is the E-R model for? External, Conceptual, Logical, or Physical modeling? Circle one.

c) The number of attributes in a relation defines the { power, degree, property, cardinality, entity } of the

relation. Circle one.

d) What is foreign key? Explain with an example.

e) Is SQL based on relational algebra or relational calculus?

f) What relational operator do we need to use to compare

  • two column values in the same row:
  • two column values in different row:

g) The order of columns in a relation is important: TRUE or FALSE

The order of rows in a relation is important: TRUE or FALSE A relation can have two columns with the same name TRUE or FALSE A relation can have an extension with no tuples. TRUE or FALSE

h) Circle TRUE or FALSE for the following statements:

A superkey is a set of one or more attributes that TRUE FALSE

identify an entity or relationship A candidate key is also a superkey TRUE FALSE A primary key is a candidate key TRUE FALSE A primary key is a superkey TRUE FALSE

A minimal superkey is a candidate key TRUE FALSE A foreign key is a primary key of some relation TRUE FALSE A relation can have at most one foreign key. TRUE or FALSE

i) A query language called Quel has queries of the form:

range of s is borrower range of t is loan retrieve (t.customer-name) where s.branch-name="Perryridge" and t.loan-number=s.loan-number Is Quel a procedural or a non-procedural language? Circle one: PROCEDURAL NON-PROCEDURAL

Is Quel a tuple or a domain calculus language? TUPLE DOMAIN

3. Functional Dependencies [7] Consider the following relation and the functional dependencies on it:

R(A,B,C,D,E,) : A Æ BC CD Æ E B Æ D E Æ A

a) Show that there are not any extraneous attributes in the above FD’s. Illustrate for each possible extraneous attribute that it is not.

b) Find all candidate keys. Then argue why there cannot be a candidate key with three attributes.

c) [.5] Is R in BCNF? Explain.

d) [.5] Is R in 3NF?

e) Is the decomposition R1(A,B,C) and R2(A,D,E) of R LOSSLESS or LOSSY? Circle and justify.

Is this decomposition FD preserving? YES or NO If you answer is NO, what is not preserved?

Is the decomposition R3(A,B,C,D) and R4(C,D,E) of R LOSSLESS or LOSSY? Circle and justify.

Is this decomposition FD preserving? YES or NO If you answer is NO, what is not preserved?

f) What is R1? Circle your answer BCNF 3NF NONE OF THESE

What is R2? Circle your answer BCNF 3NF NONE OF THESE

What is R3? Circle your answer BCNF 3NF NONE OF THESE

What is R4? Circle your answer BCNF 3NF NONE OF THESE

g) Using the decomposition algorithm decompose R into a lossless and BCNF relations. Then check if they it is FD preserving. ===================================================================================== h) [0 points just for fun] Compare the decomposition you obtain above with this R3(A,B,C,D) R4(C,D,E). Which of these two decompositions uses more storage for the same number of tuples in the original relation R?

4. Relational Algebra & Calculus [3]

Given the following relations for a Supplier-Part-Project database where S stores the suppliers, P the parts, J

the projects, and SPJ the shipments of parts from suppliers to projects. Primary keys are

underlined.

S( S# , SNAME, STATUS, CITY ) J( J# , JNAME, CITY )

s1 microsoft bad redwood j1 abb washington s2 halliburton excellent Nassau j2 shock bagdad s3 ibm good sanjose j3 tiger rome

P( P# , PNAME, COLOR, WEIGHT, CITY ) SPJ( S#, P#, J#, QTY )

p1 winXP blue 2 mandras s1 p2 j1 10 p2 as400 red 6 sanjose s2 p1 j2 20 p3 perl yellow 2 brighton s2 p4 j2 70 p4 oracle green 9 sanmateo s3 p1 j1 40

a) [.5] Write a relational algebra expression to find the supplier names (SNAME) who have shipped yellow

parts.

b) [.5] Show the output of the left outerjoin J SPJ

J.J# = SPJ.J#

c) Give a relational algebra expression to find the parts in P that have never been shipped. This is the anti-

semijoin, i.a. the tuples of P that have not received any shipments at all.

d) Give the equivalent relational algebra expression for the following SQL statements:

. SQL Relational Algebra

select *

from S Î

where S#=

select S#,SNAME

from S Î

select *

from S,SPJ Î

where S.S# = SPJ.S#

select * Î

from S,P