My question is how to make this work basically an office and non office workers can have more than one loan but since our loan id primary key I can't more than one any ideas how to do this?
CREATE TABLE loaner
(
l_id NUMBER(10) primary key,
type VARCHAR2(20),
no_days_overdue NUMBER(3),
loan_start_date date,
loan_end_date date,
fine_imposed NUMBER(55),
constraint loaner_uk unique (l_id, type),
constraint chk_type check (type='office' or type='nonoffice')
);
commit;
CREATE TABLE office
(
office_id NUMBER(5) primary key,
l_id NUMBER(10) ,
type VARCHAR2(10),
office_forname VARCHAR2(30),
office_surname VARCHAR2(30),
email VARCHAR2(50),
address VARCHAR2 (100),
constraint office_fk foreign key (l_id, type) references loaner (l_id, type),
constraint office_type_chk check (type='OFFICE')
);
commit;
CREATE TABLE nonoffice
(
nonoffice_id NUMBER(5),
l_id NUMBER(5),
type VARCHAR2(10),
non_forname VARCHAR2(30),
non_surname VARCHAR2(30),
constraint nonoffice_loaner_fk foreign key (l_id, type) references loaner (l_id, type),
constraint nonoffice_type_chk check (brw_type='nonoffice')
);
commit;