create table Inventory( I_FlowerNumber number , I_Location varchar(20), I_Condit
ID: 3870563 • 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),
v_vendorID VARCHAR(20),
ITEM_NUMBER int NOT NULL,
CONSTRAINT pk_purchase_order PRIMARY KEY (order_number),
FOREIGN KEY (V_VendorID) REFERENCES vendor(V_VendorID),
FOREIGN KEY (ITEM_NUMBER) REFERENCES Inventory(I_FlowerNumber)
);
I need to answer the question below using the information above. I am having trouble getting the commands to work without getting error messages. What information do I need to enter in the parenthesis below to make the commands work?
insert into purchase_order (order_number, order_name, customer_address , customer_zip, customer_city , order_total,v_vendorID,ITEM_NUMBER)
values (5, 'Happy', '', 8, '', '','123','300');
Explanation / Answer
Hi,
Nothing is worng with the insert query that problem here is that v_vendorID has foriegn key relation with table vendor. So in insert query you are trying to insert the record with v_vendorID as 123 which is not there in vendor table. Please make a record first in vendor tabble with v_vendorID as 123 and try to execute this query it will work.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.