Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This practice lab provides you the opportunity to create tables, primary keys and foreign keys with the use of SQL commands. The lab will utilize

This practice 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 Microsoft SQL studio)

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 (AT THE END OF THE QUESTION) and execute the script in your own folder in VLABS SQL Server.

Provide evidence of successful execution by copy/pasting the commands and the resulting execution display into the document that you are submitting for this lab.

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 in Chapter 3 of the textbook.

PART 3

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.

Copy/paste all your SQL commands into the document that you are submitting for this lab.

Provide the commands into the file IN THE ORDER that you execute the commands.

YOUR PRACTICE ASSIGNMENT

You will need to run the script in your own personal database rather than the shared one used previously. 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.

SCRIPT:

/* Script to build tables for FLIX2YOU .. current schema before revision */ /* Gary Heberling May 2, 2012 */ /* For IST210 world campus Penn State University */ /* This script will create 7 tables of the FLIX2YOU database along with primary and foreign keys */ /* Modifications to script: (1) reversed order of drop table financial_transactions and account; 1/3/13 by glh */ /* Drop tables that may already exist */ /* The following code is commented out and is available for your use if you need to drop all the tables DROP TABLE movie_cast; DROP TABLE financial_transactions; DROP TABLE accounts; DROP TABLE customer_rentals; DROP TABLE movies; DROP TABLE genre_codes; DROP TABLE format_types; DROP TABLE video_stores; DROP TABLE condition_codes; DROP TABLE actors; DROP TABLE customers; DROP TABLE rental_status_codes; DROP TABLE transaction_types; DROP TABLE payment_methods; */ /* create tables */ /* genre_codes */ CREATE TABLE genre_codes( genre_code int IDENTITY(1,1) NOT NULL, genre_code_description varchar(32) NOT NULL); /* format_types */ CREATE TABLE format_types( format_type_code int IDENTITY(1,1) NOT NULL, format_type_description varchar(32) NOT NULL); /* video_stores */ CREATE TABLE video_stores( store_id int IDENTITY(1,1) NOT NULL, store_name varchar(32) NOT NULL, store_address varchar(128) NOT NULL, store_city varchar(32) NOT NULL, store_state varchar(2) NOT NULL, store_zip varchar(12) NOT NULL, store_email varchar(128) NOT NULL, other_store_details varchar(512) NOT NULL); /* condition_code */ CREATE TABLE condition_codes( condition_code int IDENTITY(1,1) NOT NULL, condition_code_description varchar(32) NOT NULL); /* actors */ CREATE TABLE actors( actor_id int IDENTITY(1,1) NOT NULL, actor_gender char(1) NOT NULL, actor_first_name varchar(32) NOT NULL, actor_last_name varchar(32) NOT NULL, other_actor_details varchar(512) NOT NULL); /* movies */ CREATE TABLE movies( movie_id int IDENTITY(1,1) NOT NULL, condition_code int NOT NULL, format_type_code int NOT NULL, genre_type_code int NOT NULL, store_id int NOT NULL, release_year int NOT NULL, movie_title varchar(128) NOT NULL, movie_description varchar(1024) NOT NULL, number_in_stock int NOT NULL, rental_or_sale_or_both tinyint NOT NULL, 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Identify the four federally mandated employee benefits.

Answered: 1 week ago

Question

Define Decision making

Answered: 1 week ago

Question

What are the major social responsibilities of business managers ?

Answered: 1 week ago

Question

What are the skills of management ?

Answered: 1 week ago

Question

Question What is the advantage of a voluntary DBO plan?

Answered: 1 week ago