SQL Server Interview Question #168
What is a one-to-one relationship?
Database Design, Normalization & Advanced SQL Senior Advanced
Detailed Explanation
A one-to-one relationship means one row in one table corresponds to at most one related row in another table, and vice versa.
It can be implemented by making the dependent table's foreign key unique or by using the same key as both primary key and foreign key. One-to-one designs are useful for optional extensions, security separation, or splitting data with different lifecycle requirements.
Code Example
CREATE TABLE dbo.UserProfiles
(
UserId INT NOT NULL PRIMARY KEY,
Bio NVARCHAR(1000) NULL,
CONSTRAINT FK_UserProfiles_Users
FOREIGN KEY (UserId)
REFERENCES dbo.Users(Id)
);