Class Exercise: One-to-Many Table Administration
1. Write create table statements for the Department and Employee tables
with attribute data types and lengths based upon the data provided:
Name Type Width Constraint
---------- -------- ----- -----------
Department
deptNo int 2 primary key
dName char 10
location char 10
salary decimal 7 2 decimal places
Employee
empno int 4 primary key
ename char 10
job varchar 9
manager int 4
hireDate date
salary decimal 7 2 decimal places
2. Prepare dataload utility statements to import data into the Department and
Employee tables.
3. Employees may be related to Department by their work assignment. To
implement this relationship, alter Employee to include a deptNo column.
Use the same data type and length as specified in Department.
4. Alter Employee to specify that deptNo is to be a foreign key that references
deptNo in Department.
5. Update Employee to reflect the work assignments. Our web page has a link to
the file "DeptAssignEmp.txt". This contains a list of department assignments.
6. To illustrate the relationship between Department and Employee, create a join
view named Management that includes deptNo, dName, empNo, and eName for
corresponding Department and Employee rows with job type 'MANAGER'. Query the
Management view.