Skip to content

Dapper.SimpleSave and cardinality

Bart Read edited this page Oct 30, 2015 · 3 revisions

Overview

Cardinality, in the context of a relational database, for two related tables, describes the kind of relationship that they have with eachother.

For example, for tables A and B, respectively:

  • One to one (1:1) means one record in A is related to one record in B; we relax this definition to say at most one record in B

One to one relationship between tables A and B

  • One to many (1:N) means one record in A is related to (potentially) many records in B

One to many relationship between tables A and B

  • Many to one (N:1) means (potentially) many records in A relate to one record in B

Many to one relationship between tables A and B

  • Many to many (M:N) means (potentially) many records in A relate to (potentially) many records in B

Many to many relationship between tables A and B

Many to many relationships can't be directly modeled in a relational database so they're generally implemented using a link table. For example, for an M:N relationship between tables A and B we create a link table AB'. The relationship between A and AB' is 1:N, whilst the relationship between AB' and B is N:1. Thus we are able to link many records in A to many records in B using the AB' table.

Many to many relationship between tables A and B modelled using link table AB' to which each of the other tables is linked via a 1:N relationship

Clone this wiki locally