Create the tables and appropriate constraints based on the following ER diagram.
ID: 3660292 • Letter: C
Question
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)Explanation / Answer
This query works for MySQL / SQL Server / Oracle / MS Access: 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) );
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.