0% found this document useful (0 votes)
4 views2 pages

hw3 Fall22

The document contains a homework assignment for CS 353 Fall 2022, due on October 19, which includes two questions. Question 1 consists of SQL queries related to a movie database schema, while Question 2 involves SQL queries on a club membership database. Each query in both questions is designed to extract specific information based on given conditions.

Uploaded by

mehmetanil3361
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

hw3 Fall22

The document contains a homework assignment for CS 353 Fall 2022, due on October 19, which includes two questions. Question 1 consists of SQL queries related to a movie database schema, while Question 2 involves SQL queries on a club membership database. Each query in both questions is designed to extract specific information based on given conditions.

Uploaded by

mehmetanil3361
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

CS 353 Fall 2022

Homework 3
Due: October 19, Wednesday till midnight
You will use the Moodle course page for submission of this assignment

Q.1 [80 pts, 8 pts each] Given the following relational schema for a movie database:
Movie(m-id, title, year, genre, directorName, country, rating) directorName is a
foreign key to Director(name)
MovieStar(s-id, name, country, gender, birthYear)
StarIn(m-id, s-id) m-id is a foreign key to Movie, s-id is a foreign key to MovieStar
Director(name, birthYear, country)

For each of the following queries, give an expression in SQL.


(a) Find the title and year of the movies directed by the directors younger than 40 from
Turkey.

(b) Find the name of the female stars who appeared in the “horror” movies of the last 10 years
directed by Turkish directors.

(c) Find the name and country of the stars who are younger than 20 and appeared in the
movies of the director “Quentin Tarantino” between 2000 – 2020. Order the result by country
of stars ascending.

(d) Find the average rating of the “western” movies featured “John Wayne”.

(e) Find the directors who directed at least 3 movies last year (2021) with a rating higher than
5.0.

(f) For each year, find the highest rated movie from each country whose director is from the
same country and is younger than 30.

(g) Find the name of the directors from USA who directed “horror” movies in the last year,
that received a rating value higher than the average rating value of the movies directed by
“Alfred Hitchcock”.

(h) Find the title of the highest rated movie for each genre in each country for the last year.

(i) Find the name of the directors who have the same number of movies as “Tarantino”.

(j) For each country, find the name of the directors from that country who directed the highest
number of “comedy” movies in the last year.
Q.2 [20 pts, 5 pts each] Consider the following instances of a club membership database:
Student Membership Club
sid sname dept sid cid status cid cname fee
s1 Jonh CS s1 c1 null c1 ABC null
s2 Dave null s1 c2 active c2 XYZ 45
s2 c2 null
For each query below indicate what result is returned:
(a)
SELECT S.sname as StudentName, C.cname as ClubName
FROM Student S, Membership M, Club C
WHERE S.sid = M.sid AND M.cid = C.cid AND (dept = “CS” OR fee = 45)
(b)
SELECT S.sname as StudentName, C.cname as ClubName
FROM Student S, Membership M, Club C
WHERE S.sid = M.sid AND M.cid = C.cid AND (status = “active” OR status <> “active”)
(c)
SELECT S.sname as StudentName, C.cname as ClubName
FROM Student S, Membership M, Club C
WHERE S.sid = M.sid AND M.cid = C.cid AND
((dept = “CS” OR status = “active”) AND NOT(fee = 45))
(d)
SELECT S.sname as StudentName, C.cname as ClubName
FROM Student S, Membership M, Club C
WHERE S.sid = M.sid AND M.cid = C.cid AND
((dept = “CS” AND status = “active”) OR fee = 45)

You might also like