Movie Database - Database Theory - Homework, Exercises of Introduction to Database Management Systems

In the course of the database theory, we study the key concept regarding the database. The major points in these homework exercises are:Movie Database, Two Relations, Currently Playing Movies, Relational Calculus, Relational Algebra, Nr-Datalog, Division Binary Operator, Universal Quantification, Containing Tuples, Standard Algebra Operators

Typology: Exercises

2012/2013

Uploaded on 04/24/2013

bandhula
bandhula 🇮🇳

4.7

(10)

91 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CSE 233 Spring, 2012
Problem Set #1
Due on Tuesday , April 24
This is an individual assignment and the usual criteria for academic
integrity apply. Please typeset your answer (latex recommended). More
difficult problems are marked with ?.
1. The movie database consists of the following two relations
movie: title, director, actor
schedule: theater, title
The first relation provides titles, directors, and actors of various movies.
Assume a movie is uniquely identified by its title. Do not assume that
a movie has a unique director (so a movie by Hitchcock is one for which
one of the directors is Hitchcock). The second relation provides the titles
of currently playing movies and the theaters where they are being shown.
Express the following queries in (i) relational calculus, (ii) relational algebra
and (iii) nr-Datalog¬.
(a) List the theaters showing some movie by Hitchcock.
(b) List the theaters showing only movies by Hitchcock.
2. The division binary operator ÷on relations is defined as follows. Given
relations Pand Qfor which att(Q)att(P), P÷Qis a relation with
attributes att(P)att(Q) containing the tuples tfor which {t}1QP.
For example, if att(P) = {A, B}and att(Q) = {B},P÷Qis the relation with
attribute {A}containing the tuples haifor which ha, bi Pfor every tuple
hbi Q. Intuitively, ÷is a direct implementation of universal quantification.
(i) Use ÷(and standard algebra operators) to express the query “List the
theaters showing every movie by Hitchcock”.
(ii) Show how P÷Qcan be expressed using the standard relational algebra
operators (you can assume, for simplicity, that att(P) = {A, B}and
att(Q) = {B}).
1
Docsity.com
pf2

Partial preview of the text

Download Movie Database - Database Theory - Homework and more Exercises Introduction to Database Management Systems in PDF only on Docsity!

CSE 233 Spring, 2012

Problem Set

Due on Tuesday , April 24

This is an individual assignment and the usual criteria for academic integrity apply. Please typeset your answer (latex recommended). More difficult problems are marked with ?.

  1. The movie database consists of the following two relations

movie: title, director, actor schedule: theater, title

The first relation provides titles, directors, and actors of various movies. Assume a movie is uniquely identified by its title. Do not assume that a movie has a unique director (so a movie by Hitchcock is one for which one of the directors is Hitchcock). The second relation provides the titles of currently playing movies and the theaters where they are being shown. Express the following queries in (i) relational calculus, (ii) relational algebra and (iii) nr-Datalog¬.

(a) List the theaters showing some movie by Hitchcock.

(b) List the theaters showing only movies by Hitchcock.

  1. The division binary operator ÷ on relations is defined as follows. Given relations P and Q for which att(Q) ⊂ att(P ), P ÷ Q is a relation with attributes att(P ) − att(Q) containing the tuples t for which {t} 1 Q ⊆ P. For example, if att(P ) = {A, B} and att(Q) = {B}, P ÷Q is the relation with attribute {A} containing the tuples 〈a〉 for which 〈a, b〉 ∈ P for every tuple 〈b〉 ∈ Q. Intuitively, ÷ is a direct implementation of universal quantification.

(i) Use ÷ (and standard algebra operators) to express the query “List the theaters showing every movie by Hitchcock”.

(ii) Show how P ÷Q can be expressed using the standard relational algebra operators (you can assume, for simplicity, that att(P ) = {A, B} and att(Q) = {B}).

Docsity.com

  1. Consider the following query on the above schedule relation:

Find the theaters showing more than one title

(i) Express this query in relational calculus and relational algebra.

(ii) (?) Prove that every relational algebra expression defining the above query must use the attribute renaming operator δ.

  1. Prove that the conjunctive queries are not closed under union and dif- ference (i.e., exhibit conjunctive queries q 1 and q 2 such that q 1 ∪ q 2 is not equivalent to any conjunctive query, and similarly for difference).

Docsity.com