DBS Lab 01
DBS Lab 01
DBS Lab 01
Report by
Class BSSE-4A
Supervisor Rashid Mehmood Rafiq
CSC371: Database Systems – SPRING 2021
LAB Assignment – 1
Querying Relational Database using Relational Algebra
1. List the first and last names of all the female actors. [2]
Query: πfirst_name,last_name (σgender='F' ( actors ))
2. List the first and last names of all the actors who have played the role of
Doctor. [2]
Query: 1. πactors.first_name,actors.last_name (σroles.role='Doctor' (actors ⨯ roles))
2. πfirst_name,last_name ( σrole='Doctor' ( actors ⨝ roles ) )
3. List the first and last names of all the directors who are also actors. [2]
Query:
πdirectors.first_name,directors.last_name(σactors.first_name=directors.first_name∧actors
.last_name=directors.last_name ( actors ⨯ directors ))
4. List movie names along with their director names of all the movies with
a rank greater than 8.5 [2]
Query: πname,first_name,last_name (σrank>8.5 ( movies ⨯ directors ) )
5. List titles of all the movies that are released after 2000, have a rank
greater than 8, and that belong to Action genre. [2]
Query: πname (σrank>8 ∧ year>2000 ∧ genre='Action' ( movies ⨯ movies_genres ) )
6. List the first and last names of all the actors who played a role in the
movie Reservoir Dogs, and the roles they played in it. [2]
Query: πfirst_name,last_name,roles.role ( σmovies.name='Reservoir Dogs' ∧
roles.movie_id = movies.id (movies x (σ id = actor_id (actors x roles))))
7. List the first and last names of all the actors who acted in the movies of
director Quentin Tarantino but not in the movies of director Stanley
Kubrick. [3]
Query: A = movies_directors ⨝ movies_directors.director_id=directors.id directors
B = roles ⨝ actors.id=roles.actor_id actors
πactors.first_name,actors.last_name(σ(directors.first_name='Quentin'∧directors.last_nam
e='Tarantino') ∧ (directors.first_name!='Stanley' ∧ directors.last_name!='Kubrick') (A ⨝
movies_directors.movie_id = roles.movie_id B))