I have some other questions to your answer.
Quote:
create table product(
pro_id char(10) not null primary key,
pro_name varchar(20) check (pro_name in('airplane','helicopter','boat','car')),
pro_model varchar(50),
pro_color varchar(10),
pro_type char(11) check (pro_type in ('electronic','gas')),
pro_enginesize int check (pro_enginesize in (1,2,3,4)),
pro_speed KM,
pro_weight KG,
pro_qty int check (pro_qty >1)
);
|
The DDL in your answer include check constraints.
Q1) Two(for pro_name and pro_type) are too restrictive.
Even if the actual list were longer than that, constant list for these columns seems not practical.
Do you realy want to use such constraints?
For example:
If I designed the tables, I want to create product_name table and add foreign key constraint on product table referencing the product_name table.
Q2) If pro_qty get to one, do you want to delete the row?
Or do you want not to update the row, if "set pro_qty = pro_qty -1" made pro_qty to 1?
Anyhow, I felt that the check constraint itself was not practical.