POTD 5: Query cost estimation

Due 31-Mar-2026  2-April-2026, 1pm EST

Purpose:

You may make a copy of a worksheet and complete this activity, type your answers in any text editor, or simply write on paper(s).

You may work alone or with 2-3 other students in this course.


Consider the following relations:
Actor (pid, fname, lname, gender)
Movie (mid, name, year, revenue)
Directors (did, fname, lname)
Casts (pid, mid, role)
Movie_Directors (did, mid) 
with the following properties:
T(Directors)            = 480 = number of tuples in relation Directors
V(Directors, fname)	= 360 = number of distinct values of attribute fname in Directors
V(Directors, lname)	= 440 = number of distinct values of attribute lname in Directors

T(Movie)                = 450 = number of tuples in relation Directors
V(Movie, year)          = 120 = number of distinct values of attribute year in Movie

T(Movie_Directors)      = 600 = number of tuples in relation Movie_Directors
V(Movie_Directors, did)	= 450 = number of distinct values of attribute did in Movie_Directors
V(Movie_Directors, mid)	= 440 = number of distinct values of attribute mid in Movie_Directors 

-- Some movies are directed by multiple directors. 
-- Some directors direct multiple movies. 
  1. Write an RA expression that is equivalent to the following SQL query
    SELECT   D.fname, D.lname, COUNT(*) AS number_movies
    FROM     Directors D, Movie_Directors MD
    WHERE    D.did = MD.did
    GROUP BY D.did, D.fname, D.lname; 
  2. Draw an RA tree representing a logical plan of the given SQL query and then estimate the number of tuples produced by the query.

    To help you practice, you should estimate the cardinality of each RA operator

  3. Based on the above query what is the range of number_movies.

Grading rubric

[Total: 10 points]: Done (or provide evidence of your attempt, full or reasonable effort)

(-2.5 points) for 24 hours late (submitted after 31-Mar-2026 1pm EST, by 1-Apr-2026 1pm EST)
(-5 points) for 48 hours late (submitted after 1-Apr-2026 1pm EST, by 2-Apr-2026 1pm EST)

Per the class discussion on 03/30, we decided to move POTD5 down by one meeting.

(-2.5 points) for 24 hours late (submitted after 2-Apr-2026 1pm EST, by 3-Apr-2026 1pm EST)
(-5 points) for 48 hours late (submitted after 3-Apr-2026 1pm EST, by 4-Apr-2026 1pm EST)


Submission


Copyright © 2026 Upsorn Praphamontripong
Released under the Creative Commons License CC-BY-NC-SA 4.0 license.
Last updated 2026-03-23 20:37