Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Home Activities: Sample Database

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 11

Home Activities

1- Write Relational algebra expressions for the following information needs over IMDB-
sample Database:

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

π first_name , last_name ( σ gender = 'F' (actors))


2 List movie names along with their director names of all the movies with a rank greater than 8.5

π movies.name,movies.rank, directors.first_name,directors.last_name (σ rank > 8.5 (σ movies.id =


movies_directors.movie_id ((σ directors.id = movies_directors.director_id (directors ⨯
movies_directors)) ⨯ movies)))
3 List titles of all the movies that are released after 2000, have a rank greater than 8, and that belong to
Action genre.

σ movies.year > 2000 ∧ movies.rank > 8 ∧ movies_genres.genre = 'Action' (σ movies.id =


movies_genres.movie_id (movies ⨯ movies_genres))
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.

π actors.first_name,actors.last_name, movies.name, roles.role (σ movies.name = 'Reservoir Dogs' (σ


movies.id = roles.movie_id ((σ actors.id = roles.actor_id (roles ⨯ actors)) ⨯ movies)))
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.

π actors.first_name,actors.last_name,directors.first_name (σ movies_directors.movie_id =
roles.movie_id ((σ actors.id = roles.actor_id (actors ⨯ roles)) ⨯ (σ directors.first_name = 'Quentin' (σ
directors.id = movies_directors.director_id (directors ⨯ movies_directors)))))
2- Write Relational algebra expressions for the following information needs over
University Database:

6 Retrieve the title of the course that is pre-req of 'Database System Concepts'

7 Retrieve the semester and the year in which ‘Einstein’ taught the course ‘Physical Principles’.

π teaches.semester, teaches.year (σ instructor.name = 'Einstein' σ instructor.ID = teaches.ID ((σ


course.course_id = teaches.course_id (course ⨯ teaches)) ⨯ instructor))
8 Retrieve the ID and the title of all courses taken by ‘Shankar’ in ‘Fall 2009’.

π course.course_id, course.title (σ student.name = 'Shankar' ∧ takes.semester = 'Fall' ∧ takes.year =


2009 (σ course.dept_name = student.dept_name ((σ course.course_id = takes.course_id (course ⨯
takes)) ⨯ student)))
9 List the name of students who did not take any course in ‘Fall 2009’.

π student.name (σ takes.semester = 'Fall' ∧ takes.year = 2009 (σ student.dept_name =


course.dept_name ((σ course.course_id = takes.course_id (course ⨯ takes)) ⨯ student)) - (σ student.ID =
takes.ID ((σ course.course_id = takes.course_id (course ⨯ takes)) ⨯ student)))
10 Find building, room number, and capacity of all classrooms in which student ‘Tanaka’ took all his
classes.

π classroom.building, classroom.room_number, classroom.capacity (σ student.name = 'Tanaka' (σ


student.dept_name = department.dept_name ((σ classroom.building = department.building (classroom
⨯ department)) ⨯ student)))

You might also like