Name Patel RUdra Navinbha SUBJECT -DBMSi
ROll NO - ET22BTCO099
Batch A
Midterm practical exam
Create Following Tables with given constraints. Insert appropriate data
according to given Query.
ODD
1. From the following table, write a SQL query to find the name and year of
the movies. Return movie title, movie release year.
2. From the following tables, write a SQL query to find the director of a film
that cast a role in 'Ravan'. Return director first name, last name.
3. From the following table, write a SQL query to find out who was cast in the
movie 'Annie Hall'. Return actor first name, last name and role.
4. From the following table, write a SQL query to find the director who directed
a movie that featured a role in ‘Pathan'. Return director first name, last name
and movie title.
1. From the following table, write a SQL query to find the name and year of
Name Patel RUdra Navinbha SUBJECT -DBMSi
ROll NO - ET22BTCO099
the movies. Return movie title, movie release year.
create table movie(mov_id integer Primary key,mov_title char(50),mov_year
integer,mov_time integer,mov_lang char(50),mov_dt_rel date,mov_rel_country
char(5));
insert into movie(mov_id
,mov_title,mov_year,mov_time,mov_lang,mov_dt_rel,mov_rel_country)
values(1,'Bhagban',2010,9,'hindi','10-3-2010','India');
insert into movie(mov_id
,mov_title,mov_year,mov_time,mov_lang,mov_dt_rel,mov_rel_country)
values(2,'Dhoom',2012,19,'hindi','11-09-2012','India');
insert into movie(mov_id
,mov_title,mov_year,mov_time,mov_lang,mov_dt_rel,mov_rel_country)
values(3,'FastFurious',2016,3,'English','30-5-2016','Amer');
insert into movie(mov_id
,mov_title,mov_year,mov_time,mov_lang,mov_dt_rel,mov_rel_country)
values(4,'Ravan',2020,10,'Hindi','3-6-2020','Ahem');
insert into movie(mov_id
,mov_title,mov_year,mov_time,mov_lang,mov_dt_rel,mov_rel_country)
values(5,'Annie Hall',2022,17,'English','13-8-2022','Max');
select mov_title,mov_year from movie;
2. From the following tables, write a SQL query to find the director of a film
that cast a role in 'Ravan'. Return director first name, last name.
select d.dir_fname,d.dir_lname from director d,movie_director md,movie m
where md.mov_id=m.mov_id and d.dir_id=md.dir_id;
Name Patel RUdra Navinbha SUBJECT -DBMSi
ROll NO - ET22BTCO099
3. From the following table, write a SQL query to find out who was cast in
the movie 'Annie Hall'. Return actor first name, last name and role.
create table actor
act_id integer Primary key,
act_fname char(20),
act_lname char(20),
act_gender char(1));
create table movie_cast(
act_id integer,
mov_id integer,
role char(20));
insert into actor(act_id,act_fname,act_lname,act_gender)
values(1,'salman','khan','M');
insert into actor(act_id,act_fname,act_lname,act_gender)
values(2,'priyanka','chopra','F');
Name Patel RUdra Navinbha SUBJECT -DBMSi
ROll NO - ET22BTCO099
insert into movie_cast(act_id,mov_id,role)
values(1,3,'hero');
insert into movie_cast(act_id,mov_id,role)
values(2,5,'heroine');
select a.fname,a.lname,m.role from actor a,movie_cast m,movie mo
where mo.mov_title='Annie Hall' and m.act_id=a.act_id and
mo.mov_id=m.mov_id;