0% found this document useful (0 votes)
17 views7 pages

Department of Cs & Ai SUBJECT: DBMS Assignment-6 BATCH 7, 8 and 9

Uploaded by

karan20067852
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)
17 views7 pages

Department of Cs & Ai SUBJECT: DBMS Assignment-6 BATCH 7, 8 and 9

Uploaded by

karan20067852
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/ 7

DEPARTMENT OF CS & AI

SUBJECT: DBMS Assignment-6 BATCH 7, 8 and 9

Name : Karanraj
Ht no : 2203A51241
Batch : 07

Task 1:
Consider the schema for Movie Database:

ACTOR (Act_id, Act_Name, Act_Gender)

Command :

create table ACTOR_1214(act_id int primary key,act_name varchar(10),act_gender varchar(10));

DIRECTOR (Dir_id, Dir_Name, Dir_Phone)

Command :

create table DIRECTOR_1241(dir_id int primary key,dir_name varchar(10),dir_phno int


check(length(dir_phno)=10));

MOVIES (Mov_id, Mov_Title, Mov_Year, Mov_Lang, Dir_id)

Command :

Create table MOVIES_1241(Mov_id int primary key, Mov_Title varchar(15), Mov_Year date,
Mov_Lang varchar(10), Dir_id int ,foreign key(Dir_id) references DIRECTOR_1214(dir_id));
MOVIE_CAST (Act_id, Mov_id, Role)

Command :

create table MOVIE_CAST_1241(Act_id int,mov_id int,role varchar(10),foreign key(Act_id) references


ACTOR_1214(Act_id),foreign key(mov_id) references MOVIES_1241(mov_id));

RATING (Mov_id, Rev_Stars)

Command :

Create table RATING_1241(Mov_id int , Rev_Stars int , foreign key(Mov_id) references


MOVIES_1241(Mov_id));

Create the above tables by properly specifying the primary keys and the foreign keys.
Enter at least five tuples for eachrelation.

List the titles of all movies directed by ‘Hitchcock’ and ‘Spielberg’

Command : select m.mov_title from MOVIES_1241 m,DIRECTOR_1241 d where d.dir_id=m.dir_id and


d.dir_name in ('hitchcock','speilberg');

Find the names of the actors who acted in two or more movies.

Command : select distinct a.act_name from ACTOR_1214 a,movie_cast_1241 m where a.act_id=m.act_id group
by a.act_id,a.act_name having count(distinct a.act_name)>=2;
List all actors who acted in a movie before 2000

Command : select a.act_name from ACTOR_1241 a,MOVIES_1241 m,MOVIE_CAST_1241 mc where


a.act_id=mc.act_id and m.mov_id=mc.mov_id and m.mov_year<2000;

Find the title of movies and number of stars for each movie directed by RGV.

Command : select mov_title,rev_stars from MOVIES_1241 m,RATING_1241 r,DIRECTOR_1241 d


where m.mov_id=r.mov_id and d.dir_id=m.dir_id and dir_name='rgv';

Update rating of all movies directed by ‘Steven Spielberg’ to 5.

Command : update RATING_1241 set rev_stars=5 where mov_id in (select mov_id from MOVIES_1241
where dir_id=(select dir_id from DIRECTOR_1241 where dir_name='spielberg'));
List all the movies directed by any director which have four star rating

Command : select m.mov_title from MOVIES_1241 m,RATING_1241 r where m.mov_id=r.mov_id and


r.rev_stars=4;

List the names of the movies with five star rating

Command : select m.mov_title from MOVIES_1241 m,RATING_1241 r where m.mov_id=r.mov_id and


r.rev_stars=5;

List the names of the directors who directed five star rating movies

Command : select d.dir_name from DIRECTOR_1241 d,MOVIES_1241 m,RATING_1241 r where


r.mov_id=m.mov_id and m.dir_id=d.dir_id and r.rev_stars=5;

List the names of the movies acted by tom hanks and Johnny depp

Command : select m.mov_title from MOVIES_1241 m,MOVIE_CAST_1241 mc,ACTOR_1214 a where


mc.act_id=a.act_id and mc.mov_id=m.mov_id and a.act_name in ('johnnydeep','tomhanks');
Display the review star rating of movies directed by Spielberg

command : select m.mov_title,r.rev_stars from MOVIES_1241 m,RATING_1241 r,DIRECTOR_1241 d


where r.mov_id=m.mov_id and m.dir_id=d.dir_id and d.dir_name='spielberg';

Task 3:
Consider the following schema for a Library Database:
BOOK (Book_id, Title, Publisher_Name, Pub_Year)

Command : create table book_1241(b_id int primary key,b_title char(10),p_name varchar(15),year


number(4),foreign key(p_name) references publisher_1241(p_name));

BOOK_AUTHORS (Book_id, Author_Name)

Command : create table book_authors_1241(b_id int ,au_name char(10),foreign key(b_id) references


book_1241(b_id));
BOOK_COPIES (Book_id, Branch_id, No_of_Copies)

Command : create table book_copies_1241(b_id int,bran_id int,no_of_copies


int ,foreign key(bran_id) references library_branch_1241(bran_id),foreign
key(b_id) references book_1241(b_id));

BOOK_LENDING (Book_id, Branch_id, Card_No, Issued_Date, Due_Date)

Command : create table book_lend_1241(b_id int,bran_id int,card_no int,issued_date date,due_date date,foreign


key(b_id) references book_1241 (b_id),foreign key(bran_id) references library_branch_1241(bran_id));

LIBRARY_BRANCH (Branch_id, Branch_Name, Address)


Command : create table library_branch_1241(bran_id int primary key,bran_name
char(10),bran_addr varchar(15));

Create the above tables by properly specifying the primary keys and the foreign keys.
Enter at least five tuples for eachrelation.

1. Retrieve details of all books in the library – id, title, name of publisher etc.

2. Get the particulars of borrowers who have borrowed more than 3 books
3. Delete a book in BOOK table.
4. Display the names of the books that have more than 100 copies in the library
5. Display the list of all books and its number of copies that are currently available in the Library.
6. List the names of the books that are barrowed with a publisher name McGraw Hill
7. List the authors of the books published in year 2020 and 2021
8. List the titles of the books borrowed between 01/06/2021 and 10/06/2021
9. Display the names of the books that have at least one copy in the library

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy