Question: . Open a text editor to begin writing your SQL script that will contain your SQL statements. ( You may use any program that allow

. Open a text editor to begin writing your SQL script that will contain your SQL statements. (You may use
any program that allow you to create .sql files (e.g., Notepad, Wordpad, Notes, TextEdit, Notepad++,
etc.)
2. Name the file M02_HOL_LastName_FirstName.sql (e.g., M02_HOL_Doe_John.sql).
3. Complete steps B-D below.
4. Save the statements in your script in the order in which the tables should be created (based on the
foreign key constraints).
5. Execute your script to ensure it runs without errors. (If your code produces errors, work to resolve them
before submitting.)
6. Save the script and upload it as your submission.
Points will be deducted if a .sql file is not submitted. Your script should contain 5 CREATE TABLE
statements, 11 ALTER TABLE statements (5 primary key, 5 foreign key, 1 unique key),1 multi-line
comment, and 3 single-line comments.
B. Creating Tables (30 points)
1. Write CREATE TABLE statements to create the tables listed below. Do not include constraints (i.e.,
primary keys, foreign keys) in your statements. Make sure you choose the appropriate data types and
do not forget to set the columns marked as mandatory in the diagram as NOT NULL in your statement.
CUSTOMERS
BOOKS
BOOK_CATEGORY
ORDERS
ORDER ITEMS
C. Creating Constraints (20 points)
1. Write ALTER TABLE statements to add primary key constraints to the tables you created in step 1. The
constraints you create should match the primary keys displayed in the ERD.
2. Write ALTER TABLE statements to add foreign key constraints to the tables you created in step 1. The
constraints you create should match the foreign keys displayed in the ERD.
+

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!