Q:

What is foreign key?

Foreign Key is a non-key attribute which is derived from the primary key 
of another table which links those tables together.
1

CREATE TABLE Orders
(

   
OrderID int NOT NULL,

   
OrderNumber int NOT NULL,

   
PersonID int,

   
PRIMARY KEY (OrderID),

   
FOREIGN KEY (PersonID) REFERENCES Persons(PersonID)

); 
1

ALTER TABLE Orders

ADD CONSTRAINT FK_PersonOrder

FOREIGN KEY (PersonID)
REFERENCES Persons(PersonID); 
0

New to Communities?

Join the community