create table Inventory( I_FlowerNumber number , I_Location varchar(20), I_Condit
ID: 3889842 • Letter: C
Question
create table Inventory( I_FlowerNumber number , I_Location varchar(20), I_Condition varchar(20), I_Search varchar(40),I_Delete varchar(20), I_Add number,I_Quantity number,PRIMARY KEY (I_FlowerNumber));
create table vendor (V_VendorID VARCHAR(20) ,V_PhoneNumber NUMBER, V_Address VARCHAR(20), V_DirectToStore VARCHAR(10), V_Status VARCHAR(5), V_LastUpdatedBy DATE, V_Password VARCHAR(10), V_LasteUpdateTime TIMESTAMP, PRIMARY KEY(V_VendorID ) );
CREATE TABLE purchase_order (
order_number int NOT NULL,
order_name char(50) NOT NULL,
customer_address char(50),
customer_zip int, customer_city char (50),
order_total varchar(50),
CONSTRAINT purchase_order_pk PRIMARY KEY (order_number) );
How PO can you link to Vendor – add an FK to PO of V_VendorID?
How do you link between Inventory and PO must include a PO_ITEM_NUMBER table to link Inventory and PO?
Explanation / Answer
CREATE TABLE purchase_order (
order_number int NOT NULL,
order_name char(50) NOT NULL,
customer_address char(50),
customer_zip int, customer_city char (50),
order_total varchar(50),
vendor_ID VARCHAR(20),
ITEM_NUMBER number,
CONSTRAINT purchase_order_pk PRIMARY KEY (order_number),
FOREIGN KEY fk_vendor(vendor_ID) REFERENCES vendor(V_VendorID)
FOREIGN KEY fk_inventory(ITEM_NUMBER) REFERENCES Inventory(I_FlowerNumber)
);
The highlighted lines, create the relationship between Purchase order table and Inverntory, Vendor tables.. Using the foreign keys, we can find the name of the item in the purchase order or the vendor details.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.