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

DBMS & SQL 

 
ASSIGNMENT-2

Name: Kavin.M
RRN: 200171601021
COURSE: B.TECH
BRANCH: Artificial Intelligence & Data Science

1. Write SQL queries to create tables Movies, Reviewers, Cast, Actors


with  appropriate data types and set primary keys-mid for Movies
database,  Reviewer_ID for Reviewers database, Actid for Actors
Database.

2. Write SQL queries to insert the values given in the 4 above tables.
3. Write a SQL query to find the movies whose rating is greater than
8.  Return the title, year, and rating. 
4. Write a SQL query to find the movie that casted a role as ‘Tantoo’.
Return  movie title, Actname, Gender and Age.

5. Write a SQL query to find the movies whose rating is done by


‘Rotten  Tomatoes’. 

6. Write a query in SQL to create a view, which contain the fields -


movie  title, name of the female actors, role, date of release, and
rating of that  movie.

II. Design an ER Diagram for Movie Recommendation System. (Consider the


above four tables given and in addition you can extend your design)
III. Consider the below Student database: 

RRN  Subject_ID  Subject  Teacher_Name  Exam Name  Total


Marks

101  1,2  CN,DBMS  Mr.X,Mr.Y  Theory,Practical  60,40

103  2,3  DBMS,OS  Mr.Y,Mr.Z  Practical,Theory  40,60

102 4,5 C,C++  Mr.W,Mr.V  Practical,Practical  40,40

104   2 DBMS  Mr.Y  Practical  40

105  1,3  CN,OS  Mr.X,Mr.Z  Theory,Theory  60,60

i). Normalize the above table to 1 NF then 2 NF and then 3 NF

1 NF Form:

RRN Subject_ID Subject Teacher_Name Exam_Nam Total


e Marks
101 1 CN Mr.X Theory 60
101 2 DBMS Mr.Y Practical 40
103 2 DBMS Mr.Y Practical 40
103 3 OS Mr.Z Theory 60
102 4 C Mr.W Practical 40
102 5 C++ Mr,V Practical 40
104 2 DBMS Mr.Y Practical 40
105 1 CN Mr.X Theory 60
105 3 OS Mr.Z Theory 60

2 NF:

Table Schema- { RRN, Subject_ID, Subject, Teacher_Name, Exam_Name,


Total Marks}

{ RRN, Exam_Name, Total Mark} -> Table 1

{ Subject_ID, Subject, Teacher_Name, Exam_Name} -> Table 2


3NF:

For the Table 1 { RRN, Exam_Name, Total Mark}

Here we need not to change.

For the Table 2 { Subject_ID, Subject, Teacher_Name, Exam_Name}

 Into 3NF: { Subject_ID, Subject, Teacher name}


 Into 3NF: { Teacher name, Exam name}

ii). State the Finalized tables after 3NF

For Table 1:

RRN Exam_Name Total Marks


101 Theory 60
101 Practical 40
103 Practical 40
103 Theory 60
102 Practical 40
102 Practical 40
104 Practical 40
105 Theory 60
105 Theory 60

For Table 2:

{ Subject_ID, Subject, Teacher_Name}

Subject_ID Subject Teacher_Name


1 CN Mr.X
2 DBMS Mr.Y
3 OS Mr.Z
4 C Mr.W
5 C++ Mr.V
{ Teacher Name, Exam Name}
Teacher Name Exam Name
Mr.X Theory
Mr.Y Practical
Mr.Z Theory
Mr.W Practical
Mr,V Practical

You might also like