Applications ZyBooks Labs 7 and 8 (Latest
Update) Questions & Answers
{Grade A} 100% Correct
8.2 Practice Lab 2
The Rating table has the following columns:
RatingCode—variable-length string, primary key
RatingDescription—variable-length string
The Movie table should have the following columns:
Title—variable-length string, maximum 30 characters
RatingCode—variable-length string, maximum 5 characters
Write a SQL statement to create the Movie table. Designate the RatingCode column in
the Movie table as a foreign key to the RatingCodecolumn in the Rating table. - Correct
answer CREATE TABLE Movie (
Title VARCHAR(30),
,RatingCode VARCHAR(5),
FOREIGN KEY (RatingCode) REFERENCES Rating(RatingCode)
);
8.3 Practice Lab 3
The Movie table has the following columns:
ID—integer, primary key
Title—variable-length string
Genre—variable-length string
RatingCode—variable-length string
Year—integer
A new column must be added to the Movie table:
Column name: Score
Data type: decimal(3,1)
, Write a SQL statement to add the Score column to the Movie table. - Correct answer
ALTER TABLE Movie
ADD Score DECIMAL(3,1);
8.4 Practice Lab 4
The Movie table has the following columns:
ID—integer, primary key
Title—variable-length string
Genre—variable-length string
RatingCode—variable-length string
Year—integer
Write a SQL statement to create a view named MyMovies that contains the Title, Genre,
and Year columns for all movies. Ensure your result set returns the columns in the
order indicated. - Correct answer CREATE VIEW MyMovies AS
SELECT Title, Genre, Year
FROM Movie;