0

I am creating two tables called customer and item. For the customer table customerID is the primary key and for the item table itemID is the primary key. And I am creating another table which is myOrder. In myOrdertable customerID and itemID are a compound key. I defined both the columns as foreign keys as well. Once I finish creating the tables the compound key shows fine but cutomerID does not get displayed as a foreign key like in the screen capture. [![enter image description here][1]][1]

Below is the code I used.

CREATE DATABASE FK_TEST; 

USE FK_TEST;

CREATE TABLE Customer 
(
    customerID VARCHAR(10) NOT NULL, 
    name VARCHAR(25), 
    PRIMARY KEY(customerID)
);


CREATE TABLE ITEM
(
    itemID VARCHAR(10) NOT NULL, 
    itemName VARCHAR(10), 
    PRIMARY KEY(itemID)
);

CREATE TABLE myOrder 
( 
    customerID VARCHAR(10) NOT NULL,
    itemID VARCHAR(10) NOT NULL, 
    qty FLOAT(5,2),
    PRIMARY KEY(customerID,itemID),
    FOREIGN KEY(customerID) REFERENCES Customer(customerID), 
    FOREIGN KEY(itemID) REFERENCES ITEM(itemID)
);
2

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.