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

 

OVERVIEW

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.

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 4 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 LAB 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.

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 provided:

/* 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 */

For Part 2 and Part 3 (right hand side of ERD: Customer_Rentals, Customers, Financial_Transactions, Accounts, Rental_Status_Codes, Transaction_Types, Payment_Methods)

 OVERVIEW This lab provides you the opportunity to create tables, primary

Video Stores P store_id Flix2You - ERD (Initial Design: July 2002) store_name store address store_phone store_ email other store_details Customers Movies movie id P customer d Fcondition_code Cromat-type-code Fgenre_type_code Fstore id member_yn membership_ number date_became_member customer_first_name customer_last_name customer address customer_phone customer_email Customer_Rentals Condition_Codes PR condition_code Pkitem_rental id F customer id Fmovie_id release_ year movie title movie_description number in_stock rental or sale_or_botkh rental daily_rate sale_price erental status_code eg Rental, Used for Sale. rental date_ out customer dob rental_date returned rental_amount_ due other rental_details Format Types P format_ type_code format_type_descriptiorn eg DVD, Video. Financial Transactions PRtransaction_id ?account id Fkitem_rental_ id Fprevious transaction_id FRtransaction_type_code Accounts Praccount d Fr customer id Genre Codes Movie_Cast payment-method-code account _name account_details Pgenre_code movie-id PFactor id genre_description eg Comedy. Western transaction_date transaction amount transaction_comment Actors Py actor id Transaction_Types Pk transaction_type_code Payment Methods Rental_Status_Codes Prental status code Py payment method_code actor first name actor last _name other actor_details transaction_type_description eg Payment, Refund payment_ method_description rental status_description eg Overdue. eg Cash, CC (Credit Card)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!