Comsats Atd Database Lab 1 Report
Comsats Atd Database Lab 1 Report
Objective:
The objective of this lab was to familiarize students with relational algebra
expressions for querying databases. We were required to solve queries
over two databases: IMDB-sample database and University database, by
writing corresponding relational algebra expressions.
Output:
Explanation:
This expression retrieves the first and last names from the Actors relation
where the gender is 'F' (female).
2. List movie names along with their director names of all the
movies with a rank greater than 8.5.
Explanation:
This expression selects movies with a rank greater than 8.5 and joins the
Movies, DirectedBy, and Directors relations to retrieve the movie names
and their respective director names.
3. List titles of all the movies that are released after 2000, have a
rank greater than 8, and belong to the Action genre.
Explanation:
This query selects movies released after 2000, with a rank greater than 8,
and belonging to the Action genre, by joining Movies and MovieGenre
relations.
4. 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.
Output:
Explanation:
This query retrieves the first and last names of actors who acted in
"Reservoir Dogs" and lists the roles they played by joining the Movies,
Cast, and Actors relations.
5. 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.
Explanation:
This expression retrieves actors who appeared in Quentin Tarantino's
movies but excludes those who acted in Stanley Kubrick's movies using
set difference.
Lab Task 2: Queries on University Database
Output:
Explanation:
This query retrieves the title of the course that is a prerequisite for
'Database System Concepts' by joining the Courses and Prerequisites
relations.
Explanation:
This query retrieves the semester and year when Einstein taught 'Physical
Principles' by applying selection on the Teaching relation.
Output:
Explanation:
This query lists the course ID and title of courses that Shankar took in Fall
2009 by joining the Courses and Enrollments relations.
4. List the name of students who did not take any course in ‘Fall
2009’.
Output:
Explanation:
This query retrieves the names of students who did not enroll in any
courses in Fall 2009 by performing a set difference between all students
and those enrolled in Fall 2009.
5. Find the building, room number, and capacity of all classrooms
in which student ‘Tanaka’ took all his classes.
Output:
Explanation:
This query retrieves the building, room number, and capacity of all
classrooms where Tanaka attended his classes by joining the Enrollments
and Classes relations.