Loading Page Content...
Preparing courses, live labs, and learning resources.सामग्री लोड हो रही है, कृपया प्रतीक्षा करें...
Preparing courses, live labs, and learning resources.सामग्री लोड हो रही है, कृपया प्रतीक्षा करें...
In relational database engineering, relationships define how records in one table correlate with records in another. A One-to-One (1:1) relationship means that a single record in Table A is associated with at most one record in Table B, and vice versa.
While beginners often ask: "Why not just put all columns in a single table?", experienced database architects know that 1:1 relationships are critical for security isolation, performance optimization, and vertical partitioning.
Why split data into two tables linked in a 1:1 relationship?
users (readable by all services) and isolate sensitive fields (tax ID, KYC documents, banking details) in user_tax_details with strict table-level access permissions.InnoDB, reading narrow tables is significantly faster. Storing frequently read columns (username, email) in one table and rarely read wide columns (PDF resumes, JSON metadata) in a child table keeps your main table's pages compact in the Buffer Pool.NULL values.A 1:1 relationship is enforced by placing a Foreign Key in the dependent table and applying a UNIQUE constraint on that foreign key column!
Instead of generating a separate surrogate key (passport_id), the child table can use the exact same Primary Key as the parent table, doubling as both Primary Key and Foreign Key:
UNIQUE constraint, the database engine will allow multiple child rows per parent, inadvertently creating a One-to-Many (1:N) relationship!ON DELETE CASCADE on 1:1 auxiliary detail tables so that deleting a user automatically cleans up their associated preferences and passport records.Continue learning with hands-on practice, examples, and exercises in the upcoming topic.
| Previous Lesson | Next Lesson |
|---|---|
| None | One-to-Many (1:N) Relationships |
Test your understanding of this lesson with 5 questions. Each question has one correct answer.