Question
This lab provides you the opportunity to create tables, primary keys and foreign keys with the use of SQL commands. The lab will utilize the
This lab provides you the opportunity to create tables, primary keys and foreign keys with the use of SQL commands. The lab will utilize the FLIX2YOU problem.
In the FLIX2YOU product document, there is an Entity Relationship Diagram (ERD) showing the current database schema for FLIX2YOU. You will also find a script file named FLIX2YOU_current.txt The execution of the script file in SQL Server Management Studio will create seven of the fourteen tables for the FLIX2YOU database. The script will create the tables along with the primary and foreign keys for the seven table displayed on the left hand side of the ERD.
PART 1
The first part of this lab you will use the script provided and execute the script in your own folder in VLABS SQL Server.
PART 2
The second part of the lab you will create a data dictionary for the remaining seven tables (right hand side of the FLIX2YOU ERD). The data dictionary can be a formatted Word document or an Excel spreadsheet file. Please follow the format of the sample data dictionary found on table 3.6 on page 92 of the textbook. Then you will write and execute the SQL commands in VLABS SQL Server to create the seven tables and the primary/foreign keys for those tables.
You will submit a document that includes ALL the SQL commands that you execute AND ALL the messages in SQL Server from the execution of the commands. This includes the execution of the script that has been provided to you for the first part AND the SQL commands you created for the second part of the lab.
For this lab, you will submit (1) the document containing all the SQL commands and the resulting messages from the execution and (2) the data dictionary file.
SCRIPT
rental_daily_rate money NOT NULL, sales_price money NOT NULL); /* movie_cast */ CREATE TABLE movie_cast( movie_id int NOT NULL, actor_id int NOT NULL);
/* create primary keys with ALTER TABLE statement */ ALTER TABLE genre_codes ADD CONSTRAINT pk_genre_codes PRIMARY KEY (genre_code); ALTER TABLE format_types ADD CONSTRAINT pk_format_types PRIMARY KEY (format_type_code); ALTER TABLE video_stores ADD CONSTRAINT pk_video_stores PRIMARY KEY (store_id); ALTER TABLE condition_codes ADD CONSTRAINT pk_condition_codes PRIMARY KEY (condition_code); ALTER TABLE actors ADD CONSTRAINT pk_actors PRIMARY KEY (actor_id); ALTER TABLE movies ADD CONSTRAINT pk_movies PRIMARY KEY (movie_id); ALTER TABLE movie_cast ADD CONSTRAINT pk_movie_cast PRIMARY KEY (movie_id, actor_id); /* end of primary key creation */
/* create foreign keys */ ALTER TABLE movie_cast ADD CONSTRAINT fk_Movie_cast_actors FOREIGN KEY(actor_id) REFERENCES actors (actor_id); ALTER TABLE movie_cast ADD CONSTRAINT fk_movie_cast_movies FOREIGN KEY(movie_id) REFERENCES movies (movie_id); ALTER TABLE movies ADD CONSTRAINT fk_movies_condition_codes FOREIGN KEY(condition_code) REFERENCES condition_codes (condition_code); ALTER TABLE movies ADD CONSTRAINT fk_movies_format_types FOREIGN KEY(format_type_code) REFERENCES format_types (format_type_code); ALTER TABLE movies ADD CONSTRAINT fk_movies_genre_codes FOREIGN KEY(genre_type_code) REFERENCES genre_codes (genre_code); ALTER TABLE movies ADD CONSTRAINT fk_movies_video_Stores FOREIGN KEY(store_id) REFERENCES video_Stores (store_id);
/* END OF SCRIPT */
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started