Primary Key
- Uniquely identifies each row.
- A table can have only one primary key, but it may consist of multiple columns (composite key).
Foreign Key
- Ensures referential integrity by linking two tables.
CREATE TABLE Orders (
OrderID INT PRIMARY KEY,
CustomerID INT,
FOREIGN KEY (CustomerID) REFERENCES Customers(CustomerID)
);
Leave a Reply