0% found this document useful (0 votes)
46 views2 pages

Assignment# 4

The document describes the constraints for 4 tables - locations, locations_departments, departments, and employees. It provides the attributes, data types, lengths and constraints for each table. Sample data is provided for the locations and departments tables. The assignment tasks are to: 1) Create the 4 tables with constraints, 2) Insert the sample data, 3) Test each constraint by inserting invalid data to force errors and validate the constraints are working, and 4) Generate an ERD of the tables.

Uploaded by

Danveer Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views2 pages

Assignment# 4

The document describes the constraints for 4 tables - locations, locations_departments, departments, and employees. It provides the attributes, data types, lengths and constraints for each table. Sample data is provided for the locations and departments tables. The assignment tasks are to: 1) Create the 4 tables with constraints, 2) Insert the sample data, 3) Test each constraint by inserting invalid data to force errors and validate the constraints are working, and 4) Generate an ERD of the tables.

Uploaded by

Danveer Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Database Design & SQL CSD 2206

Assignment 4 – Constraints
(Total marks: 100, Weight: 5%)

After further analysis, the following constraints (business rules) have been determined:
1 locations
Attribute Data Type Length NULL Capable Constraints
Location ID (PK) Numeric 2,0 N
City Character 20 N
Store Manager Numeric 5,0 Y Must be a valid employee

locations data:
location_id city store_manager
11 Sarnia null
22 London null
33 Toronto null

2 locations_departments
Attribute Data Type Length NULL Capable Constraints
location ID (PK) Numeric 2,0 N Must be a valid location
department_id (PK) Numeric 4,0 N Must be a valid department
department_manager Numeric 5,0 Y Must be a valid employee

3 departments
Attribute Data Type Length NULL Capable
Department ID (PK) Numeric 4,0 N
Department name Character 50 N

departments data:
department_id department_name
1001 IT
1002 Administration
1003 Men's Clothing
1004 Women's Clothing
1005 Kids
1006 Toys

1
Database Design & SQL CSD 2206

4 employees
Attribute Data Type Length NULL Constraints
Capable
Employee ID (PK) Numeric 5,0 N  Unique identifier
First name Character 15 N
Middle Initial Character 1 Y
Last Name Character 15 N
Hire Date Date 10 N  If unknown, use current date
 Must be greater than birth date
Store Location Numeric 2,0 N  Must be a valid location
Work Department Numeric 4,0 Y  Must be a valid department

Job Class Character 1 Y  If unknown, use 'T'


 Must be 'T', 'J', 'C', or 'M'
Coach ID Numeric 5,0 Y  Must be a valid employee
Salary Numeric 9,2 N  Must be less than 92000.00
 Must be greater than commission
Bonus Numeric 7,2 Y  Must have commission or bonus
Commission Numeric 7,2 Y  Must have commission or bonus

1. Create the 4 tables and include the constraints


2. Insert the data provided in the tables: locations data and departments data.
3. Constraint Testing – Test each constraint by listing each constraint and providing a test
to validate that each constraint is working:
a. Include an INSERT statement to "force" a constraint error. For example, modify
the employee_id so that it is the same as the employee_id in the
previous row. This will force a primary key error when the INSERT statement is
run
b. Run the INSERT statement and verify that the error occurred
c. Take a screen shot of the error and insert into the constraint testing document
d. Move to the next constraint and perform a constraint test
4. Generate the ERD of the above table

You might also like