What is the difference between the relationships between tables?

Asked

Viewed 1,078 times

16

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 for several);

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

1 answer

17

This is called cardinality.

In a way what is in the question practically already says what is each one.

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

um pra umum pra um

1:N means that for each row in a table several rows will be referenced in the other table which in turn each row can only have one row referenced in the first table. In general it can be from 0 to N lines.

um pra muitosum pra muitos

M:N means that for each row in a table several rows will be referenced in the other table and the latter may have in each of its rows several references to the first table. In general it can be from 0 to N lines.

muitos pra muitosmuitos pra muitos

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

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

  • Picking on your own 1:1: https://pt.wikipedia.org/wiki/Lista_de_pa%C3%Adses_com_m%C3%Baltiplas_capitals has also Nauru, which has no capital, and Switzerland, where the capital is exceptionally not established by law, has and does not. : D

  • The capital of Nauru is Yaren, an expert in the country. It’s serious! https://www.google.com/maps/place/Nauru/@-0.5268213,166.924703,7721m/data=! 3m1! 1e3!4m5! 3m4! 1s0x6f7d1c1f1de45b4d:0x59d99df4c5d40a81! 8m2! 3d-0.522778! 4d166.931503

  • "Its most populous city is Yaren, home to the national parliament, the island’s only airport, and much of the government services. So why not establish Yaren as capital? Because the seat of executive power in this country is in another district, Meneng, so for now this country will continue without any capital." (officially declared at least). https://culturadealgibeira.wordpress.com/2018/07/13/os-dois-paises-capital/

  • And where is the officiality of it?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.