FOREIGN KEY Constraint
The FOREIGN KEY constraint is used to link two tables. It ensures that the value in a column corresponds to a value in another table's primary key or unique column.
Example: Creating a Table with FOREIGN KEY
CREATE TABLE Contributions (
ContributionID INT PRIMARY KEY,
FighterID INT,
Amount DECIMAL(10, 2),
FOREIGN KEY (FighterID) REFERENCES FreedomFighters(FighterID)
);
Explanation: The FighterID in the Contributions table is a foreign key referencing the FighterID in the FreedomFighters table, establishing a relationship between the tables.