0% found this document useful (0 votes)
42 views10 pages

Comsats Atd Database Lab 1 Report

this is lab 1 report

Uploaded by

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

Comsats Atd Database Lab 1 Report

this is lab 1 report

Uploaded by

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

Database Lab 1 Report

Course: Database Systems


Student Name: Salman Ahmad
Registration Number: FA23-BSE-098
Date: 05 October 2024

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.

Lab Task 1: Queries on IMDB-sample Database


1. List the first and last names of all the female actors.

Relational Algebra Expression:

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.

Relational Algebra Expression:


Output:

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.

Relational Algebra Expression:


Output:

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.

Relational Algebra Expression:

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.

Relational Algebra Expression:


Output:

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

1. Retrieve the title of the course that is a pre-requisite of


'Database System Concepts'.

Relational Algebra Expression:

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.

2. Retrieve the semester and the year in which ‘Einstein’ taught


the course ‘Physical Principles’.

Relational Algebra Expression:


Output:

Explanation:
This query retrieves the semester and year when Einstein taught 'Physical
Principles' by applying selection on the Teaching relation.

3. Retrieve the ID and the title of all courses taken by ‘Shankar’


in ‘Fall 2009’.

Relational Algebra Expression:

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’.

Relational Algebra Expression:

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.

Relational Algebra Expression:

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.

You might also like