Lab05 Schema Creation Using SQL
Lab05 Schema Creation Using SQL
Lab 5
Due Date:
Name ID Section
GEIT 3341 DATABASE 1 LAB 5
Instructions:
Use the CREATE TABLE command you learned in Chapter 7 and the INSERT command
you learned in Chapter 6 to create the following schema consisting of 3 tables. For each
field, pick the most appropriate data type for it. While creating the STORE table, add a
CHECK constraint to ensure that values of the STORE_YTD_SALES column are greater
than zero.
Table Name: EMPLOYEE
Primary Key: EMP_CODE
EMP_CODE EMP_LNAME EMP_FNAME EMP_DOB E MP_PHONE
1Williamson John 29-DEC-62 (06) 434-0095
2Ratula Nancy 12-MAR-67 (02) 526-1192
3Greenboro Lottie 02-NOV-59 (03) 231-6292
4Rumpersto Jennie 11-APR-64 (06) 224-1122
5Shawn Michael 23-DEC-60 (06) 599-0406
6Jones Rose 13-SEP-65 (06) 111-6262
7Rosten Peter 25-OCT-65 (02) 111-1133
8Bret Hart 12-AUG-67 (02) 796-1122
9Ron Frank 11-NOV-60 (03) 432-1356
10Elain Roberts 23-FEB-62 (06) 732-1967
After creating the three tables, use the ALTER TABLE command to add a new column
STORE_CODE to the EMPLOYEE table. Then use the ALTER TABLE command again to
designate it as a foreign that references STORE_CODE in STORE table. After this, use the
UPDATE command to set the STORE_CODE of each employee according to the following
table:
EMP_CODE STORE_CODE
1 1
2 2
3 2
4 4
5 1
6 2
7 3
8 1
9 2
10 3
Hand in:
1. The three CREATE TABLE commands for the three tables. (5 points)
2. The ALTER TABLE command to add the STORE_CODE column. (1 points)
3. The ALTER TABLE command to designate STORE_CODE as a foreign key. (1 points)
4. The UPDATE commands you used to assign a STORE_CODE for each employee.
(2 points)
5. Screen shots of the content of the three tables. (1 points)