Question: Consider the schemas and instances below. #prod should be prodid #dep should be depid. The primary key of product is prodid. The primary key of
Consider the schemas and instances below.
#prod should be prodid
#dep should be depid.
The primary key of product is prodid. The primary key of depot is depid. The composite primary key of stock is prodid, depid.
prodid in stock is a foreign key referring the primary key prodid in product.
depid in stock is a foreign key referring the primary key depid in depot.
Schemas:
Product#prod, pname, price
Depot #dep, addr, volume
Stock #prod, #dep, quantity
Instanoes:
Product
#prod pname price
p tape
p tv
p ver
Depot
#dep addr volume
d New York
d Syracuse
d New York
Stock
#prod #dep quantity
p d
p d
p d
p d
p d
p d
p d
p d
Write the code that will create the tables: product, depot and stock, and populate them with the provided data following the instructions below.
SQL code tested in PostgreSQL without syntax errors:
Instructions:
YOU WILL NOT WRITE SQL CODE THIS WAY:
CREATE TABLE Product
prodid CHAR
pname VARCHAR
price DECIMAL,
PRIMARY KEY prodid
CHECK price ;
BUT YOU WILL PROVIDE NAMES FOR ALL OF THE CONSTRAINTS AND USE ALTER TABLE:
CREATE TABLE Product
prodid CHAR
pname VARCHAR
price DECIMAL;
ALTER TABLE Product ADD CONSTRAINT pkproduct PRIMARY KEY prodid;
ALTER TABLE Product ADD CONSTRAINT ckproductprice CHECK price ;
Primary key constraints begin with pk
Foreign key constraints begin with fk
Check constraints begin with ck
Follow instructions for above question and give what exactly question want.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
