DBS211_Lab03_DDL_W24

docx

School

Seneca College *

*We aren’t endorsed by this school

Course

211

Subject

Business

Date

Apr 3, 2024

Type

docx

Pages

4

Uploaded by DeanCrabMaster1893

Report
DBS211 – Introduction to Database Systems Winter 2024 Lab 03 – SQL (DDL) Objectives: The purpose of this lab is to introduce you to the DDL set of statements in SQL. By writing SQL to create tables, constraints, and views, you will have the tools needed to implement database designs that you will create later in the course. By finishing this lab, the student will be able to: create, modify, and drop tables based on design specifications provided, enforce constraints on tables to ensure data integrity and consistency, Submission: Your submission will be a single .pdf file with the code copied from SQL Developer and output screenshots. DBS211_L03_LastName.sql Your submission needs to include a comment header block and be commented to include the questions and the solutions. Make sure every SQL statement terminates with a semicolon. Example Submission -- *********************** -- Name: Your Name -- ID: ######### -- Date: The current date -- Purpose: Lab 03 DBS211 -- *********************** -- Q1 SOLUTION -- SELECT * FROM TABLE; -- Q2 SOLUTION – SELECT * FROM TABLE; Locate, select, and submit the file to the Lab 05 link. Setup Create a new worksheet in SQL developer and add an appropriate comment header that includes your name, student id, the date and the purpose of the file (i.e. DBS211 – Lab 03).
DBS211 – Introduction to Database Systems Winter 2024 Style Guide Your SQL should be written using the standard coding style: all keywords are to be upper case, all user-defined names are to be lower case, (example: table and field names) there should be a carriage return before each major part of the SQL statements (i.e. before SELECT, FROM, WHERE and ORDER BY) See the following sample: SELECT columns FROM tables WHERE conditions ORDER BY column1, column2; Marking Scheme Question Points Question Points 1 2 8 0.5 2 0.5 9 0.5 3 0.5 10 0.5 4 1 11 1 5 1 12 0.5 6 1 13 0.5 7 0.5 Total: 10 Grade Policy Submissions with errors do not get any marks. (They get zero.) o Execute your .sql file using the “Run Script” button to make sure there is no errors in your file. If your result in a question does not match the sample output results, you do not get any marks. You do not receive marks for the missing or incomplete solutions. The name of the tables you will create in this lab have to match exactly with the names given this lab document. Tasks: Add SET AUTOCOMMIT ON; under the comment header and execute it. Consider the following table specifications:
DBS211 – Introduction to Database Systems Winter 2024 Part A (DDL) 1. Create the following tables and their given constraints: L5_MOVIES Column Name Column DataType PK Not Null Unique FK Default Value Validation m_id int title varchar(35) release_year int director int score decimal(3,2 ) < 5 and > 0 L5_ACTORS Column Name Column DataType PK Not Null Unique FK Default Value Validation a_id int first_name varchar(20) last_name Varchar(30) L5_CASTINGS Column Name Column DataType PK Not Null Unique FK Default Value Validation movie_id int (L5_MOVIES) actor_id int (L5_ACTORS) L5_DIRECTORS Column Name Column DataType PK Not Null Unique FK Default Value Validation director_i d int first_name varchar(20) last_name varchar(30) 2. Modify the L5_MOVIES table to create a foreign key constraint that refers to table L5_DIRECTORS . 3. Modify the L5_MOVIES table to create a new constraint so the uniqueness of the movie title is guaranteed.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
DBS211 – Introduction to Database Systems Winter 2024 4. Write insert statements to add the following data to table L5_DIRECTORS and L5_MOVIES . L5_Director director_id first_name last_name 1010 Rob Minkoff 1020 Bill Condon 1050 Josh Cooley 2010 Brad Bird 3020 Lake Bell L5_Movies m_id title release_year director score 100 The Lion King 2019 3020 3.50 200 Beauty and the Beast 2017 1050 4.20 300 Toy Story 4 2019 1020 4.50 400 Mission Impossible 2018 2010 5.00 500 The Secret Life of Pets 2016 1010 3.90 5. Write SQL statements to remove all above tables. Is the order of tables important when removing? Why?