Which term defines a column, or group of columns, that refers to a primary key in a different table?
A foreign key is a column (or a set of columns) that establishes a relationship between two tables by referencing the primary key of another table.
Example Usage:
sql
CREATE TABLE Departments (
DeptID INT PRIMARY KEY,
DeptName VARCHAR(50)
);
CREATE TABLE Employees (
EmpID INT PRIMARY KEY,
Name VARCHAR(50),
DeptID INT,
FOREIGN KEY (DeptID) REFERENCES Departments(DeptID)
);
DeptID in Employees is a foreign key, referencing DeptID in Departments.
Ensures referential integrity DeptID in Employees must exist in Departments.
Why Other Options Are Incorrect:
Option A (Super key) (Incorrect): A super key is any set of columns that uniquely identifies a row, but it does not reference another table.
Option B (Simple key) (Incorrect): A simple key is a single-column primary key, not a reference to another table.
Option C (Composite key) (Incorrect): A composite key consists of multiple columns but does not necessarily reference another table.
Thus, the correct answer is Foreign key, as it establishes a connection between two tables.
Della
4 days agoJacquline
9 days agoDaron
14 days ago