What is the difference between the relationships between tables?

12

I know there are three types of relationships between data from different tables:

  • 1: 1 (one-to-one);
  • 1: N (one for several);
  • N: N (several to several);

But what would be the difference between relationship types and their use in a relational database?

    
asked by anonymous 10.08.2016 / 04:03

1 answer

14

This is called cardinality .

In a way, what's in the question almost says what each one is.

1: 1 means that for each row of a table it will be referenced in one row in another table and vice versa.

1:Nmeansthatforeachrowinatablewillbereferencedseveralrowsinanothertablewhichinturneachrowcanonlyhaveonerowreferencedinthefirsttable.Ingeneralitcanbefrom0toNlines.

M:Nmeansthatforeachrowinatable,severalrowswillbereferencedintheothertable,andthelatterwillhaveseveralreferencestothefirsttableineachrow.Ingeneralitcanbefrom0toNlines.

I do not like this N: N. This implies that both have the same number, which is not true. I know a lot of people use it like that, but I prefer M: N.

It is also used, 0..1, 0 .. * or 1 .. * to indicate more precisely how many rows can be referenced at least (before the points) and at the maximum (after the points) indicating if none can be (0), must be one (1) or can be several (*).

    
10.08.2016 / 04:39