134k views
4 votes
Create the tables and appropriate constraints based on the following ER diagram. Use appropriate data types. Note that the size column should only accept S, M, or L. In addition the price column should only have values greater than zero. All columns in both tables are required. ====================== CATEGORY table: Category Cid Description ====================== PRODUCT table: pid description cid (fk) Price Size (S/M/L)

1 Answer

5 votes

Answer:

See explaination

Step-by-step explanation:

CREATE TABLE CATEGORY

(

cid int NOT NULL,

description varchar2(1000),

PRIMARY KEY (cid)

);

CREATE TABLE PRODUCT

(

pid int NOT NULL,

description varchar2(1000),

cid int,

price int,

p_size varchar2(1),

CONSTRAINT chk_price CHECK (price>0),

CONSTRAINT chk_size CHECK (p_size in ('S','M','L')),

CONSTRAINT fk_cid FOREIGN KEY (cid) REFERENCES CATEGORY(cid)

);

User TheAlphamerc
by
3.3k points