**I have created the databases already I just need the querries for # 5 that is
ID: 3916787 • Letter: #
Question
**I have created the databases already I just need the querries for # 5 that is below in bold.
1.) Create the database
2.) Create the tables in including appropriate data types (Actors, Movies, ActorMovies, Directors)
3.) Create appropriate foreign key constraints
4.) Add data including at least 5 movies, the director, and at least 3 actors from each movie (put yourself in as an actor in at least two movies)
5.) Create and run the following queries. For each query copy and paste or screenshot the query and submit the result to assignment:
a query that joins the tables and displays all actors and all movies
a query that joins the tables and displays all actors in a particular movie
a query that joins the tables and displays only the movies in which you are an actor
create two additional queries of your choice that displays the data in a way that could be useful
3.) Submit your queries and the results they produce.
Explanation / Answer
Answer)
Table Structure:
CREATE TABLE Movies (MovieID int AUTO_INCREMENT primary key, Title varchar(50), Genre varchar(20), ReleaseDate Date, MPAARating varchar(5), DirectorID int, foreign key (DirectorID) references Director(DirectorID));
create table ActorMovies(ActorID int, MovieID int, Salary int, primary key(ActorID,MovieID), foreign key (ActorID) references Actor(ActorID), foreign key (MovieID) references Movies(MovieID));
create table Actor (ActorID int AUTO_INCREMENT primary key, Fname varchar(20), Lname varchar(20), DOB date, Gender char(1));
create table Director (DirectorID int AUTO_INCREMENT primary key, Fname varchar(20), Lname varchar(20), DOB date, Gender char(1));
a query that joins the tables and displays all actors and all movies
SELECT *
FROM ((Movies
INNER JOIN ActorMovies ON Movies.MovieID = ActorMovies.MovieID)
INNER JOIN Actor ON ActorMovies.ActorID = Actor.ActorID);
a query that joins the tables and displays all actors in a particular movie
SELECT *
FROM ((Movies
INNER JOIN ActorMovies ON Movies.MovieID = ActorMovies.MovieID)
INNER JOIN Actor ON ActorMovies.ActorID = Actor.ActorID) where Movies.Title ='Titanic';
a query that joins the tables and displays only the movies in which you are an actor
SELECT *
FROM ((Movies
INNER JOIN ActorMovies ON Movies.MovieID = ActorMovies.MovieID)
INNER JOIN Actor ON ActorMovies.ActorID = Actor.ActorID) where Actor.Fname='Jack';
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.