You are on page 1of 2

Lab 3: An Algebraic Query Language

We have the database schema consists of five relations:


Movies (title, year, length, genre, studioName, producer#)

StarsIn (movieTitle, movieYear, starName)

MovieStar (name, address, gender, birthdate)

MovieExec (cert#, name, address, netWorth)

Studio (name, address, presC#)

1. Write expressions of relational algebra to answer the


following queries.
1. Find date of birth of Aishwarya Rai who is a movie star.

2. List name of the female stars in the film “Monsoon Wedding”.

3. Find name of the producer of Star Wars.

4. Find title of movies that are no longer than “Bride and Prejudice”.

5. Find name and address of all male movie stars who are also movie executives with
a net worth under $10,000,000.

2. How to express constraints via Relation Algebra


1. Two components MovieTitle and MoviewYear of each StarIn tuple must also
appear in two components Title and Year of some Movie tuple.
2. No two tuples of Movies agree on two components Title and Year.

3. Net worth of a producer must be less than Michael Bay.

4. Each Movie star must appear at least in one Movie.

5. The maximum number of movie stars of a movie must be 10.

No Symbol Description
1 R1 U R2 Set union
2 R1 - R2 Set except
3 R1 ∩ R2 Set intersection
4 πL (R) Projection
5 σC(R2) Selection
6 R1 x R2 Product
7 R1 ⋈ R2 Natural join
8 R ⋈θS Join
9 ρR1(A1,…,An)(R) Rename
10 Φ Empty set
11 Gmaker, count(model) ->
maker Aggregate functions
numberOfPcs(R) as SUM, COUNT,
MIN, MAX, AVG
(group by ‘maker’)

You might also like