I've been stuck at creating tables.
Here is the code I am stuck at how to make the code work in loan_type
to write office worker or non office worker
create table loaner
(
loan_id number(5) primary key,
loan_type VARCHAR2 (16),
loan_start_date date,
loan_end_date date,
)
create table office_worker
(
worker_id number(5) primary_key,
loan_id number(5) references loaner(loan_id),
worker_name varchar2(50)
)
create table nonoffice_worker
(
nonworker_id number(5) primary_key,
loan_id number(5) references loaner(loan_id),
nonworker_name varchar2(50)
);
commit;
You can also add a check constraint to your table, but you must check that column loan_type only contains desired values(
office worker
ornon office worker
), else this won't work:You can't create a constrain to check that with the existing table structures. A common way to do it is like this:
That is: