shlogg · Early preview
Pranav Bakare @mrcaption49

Database Relationships Explained In 5 Types

Databases define relationships between tables as 1:1, 1:N, N:1, M:N & self-referencing. Each type uses primary keys & foreign keys for data integrity. Examples include person/passport, customer/orders, employees/departments & students/courses.

Relationships in databases

In databases, relationships define how tables are linked to each other. The most common types of relationships are:

  
  
  1. One-to-One (1:1):

Each row in Table A is linked to one and only one row in Table B, and vice versa.
Example: A person and their passport. Each person has one passport, and each passport is assigned to one person.

  
  
  2. One-to-Many (1:N):

A single row in Table A can be associated with multiple rows in Table B, but each row in Table B is linked to only one row in Table A.
Example: A customer and their orders. A customer can place mult...