diff --git a/ex101/ex101.1.1/container_files/postgres/hr_depts.sql b/ex101/ex101.1.1/container_files/postgres/hr_depts.sql index c00c09a..6915f4e 100644 --- a/ex101/ex101.1.1/container_files/postgres/hr_depts.sql +++ b/ex101/ex101.1.1/container_files/postgres/hr_depts.sql @@ -1,7 +1,7 @@ create table hr_depts ( dept_id varchar(5) primary key, name varchar(60), - parent_dept_id varchar(5), + parent_dept_id varchar(5) references hr_depts (dept_id), abbrev varchar(5) ); @@ -121,10 +121,10 @@ insert into hr_depts(dept_id, name, parent_dept_id, abbrev) values /************* hr_orgs *************/ create table hr_orgs ( - dept_id VARCHAR(5) primary key, + dept_id VARCHAR(5) primary key references hr_depts (dept_id), abbrev VARCHAR(5), - min_dept_id VARCHAR(5), - max_dept_id VARCHAR(5), + min_dept_id VARCHAR(5) references hr_depts (dept_id), + max_dept_id VARCHAR(5) references hr_depts (dept_id), range_desc VARCHAR(30) ); diff --git a/ex101/ex101.1.1/container_files/postgres/hr_jobs.sql b/ex101/ex101.1.1/container_files/postgres/hr_jobs.sql index ad1ed7b..ac86308 100644 --- a/ex101/ex101.1.1/container_files/postgres/hr_jobs.sql +++ b/ex101/ex101.1.1/container_files/postgres/hr_jobs.sql @@ -1,13 +1,11 @@ /************* hr_positions *************/ create table hr_positions ( - position_id varchar(5), - dept_id varchar(5), + position_id varchar(5) primary key, + dept_id varchar(5) references hr_depts (dept_id), role varchar(10) ); -alter table hr_positions add primary key (position_id); - insert into hr_positions (position_id, dept_id, role) values ('10000','10000','staff'), ('10001','10000','staff'), @@ -1520,8 +1518,9 @@ insert into hr_positions (position_id, dept_id, role) values /************* hr_jobs *************/ create table hr_jobs ( - position_id varchar(5), - person_id varchar(10) + position_id varchar(5) references hr_positions (position_id), + person_id varchar(10), + constraint pk_hr_jobs primary key (position_id, person_id) ); insert into hr_jobs (position_id, person_id) values diff --git a/ex101/ex101.1.1/container_files/postgres/sis_courses.sql b/ex101/ex101.1.1/container_files/postgres/sis_courses.sql index 01e2b61..6343a73 100644 --- a/ex101/ex101.1.1/container_files/postgres/sis_courses.sql +++ b/ex101/ex101.1.1/container_files/postgres/sis_courses.sql @@ -2,8 +2,7 @@ create table sis_courses ( course_id integer primary key, -/* dept_id varchar(5), */ - dept_id varchar(5) references sis_acad_depts (dept_id), + dept_id varchar(5) references sis_acad_depts (dept_id), course_num varchar(5), title varchar(200) ); diff --git a/ex101/ex101.1.1/container_files/postgres/sis_enrollment.sql b/ex101/ex101.1.1/container_files/postgres/sis_enrollment.sql index 315e088..2f069f2 100644 --- a/ex101/ex101.1.1/container_files/postgres/sis_enrollment.sql +++ b/ex101/ex101.1.1/container_files/postgres/sis_enrollment.sql @@ -1,7 +1,7 @@ /************* sis_enrollment *************/ create table sis_enrollment ( - course_id integer, + course_id integer references sis_courses (course_id), person_id varchar(10), term varchar(9), role varchar(10), diff --git a/ex101/ex101.1.1/container_files/postgres/sis_programs.sql b/ex101/ex101.1.1/container_files/postgres/sis_programs.sql index daec336..823278c 100644 --- a/ex101/ex101.1.1/container_files/postgres/sis_programs.sql +++ b/ex101/ex101.1.1/container_files/postgres/sis_programs.sql @@ -130,7 +130,7 @@ create table sis_stu_programs ( grad_year_expected varchar(10), school_id varchar(10), acad_dept_id varchar(10) references sis_acad_depts (dept_id), - prog_status_id varchar(2), + prog_status_id varchar(2) references sis_prog_status (prog_status_id), constraint pk_sis_stu_programs primary key (person_id, program_idx) );