Good day!
I have a question for someone that may seem silly, but I still can’t understand how the connections work (one to many, one to one, etc.).
I have 2 User tables and Rule. The Rule table stores access rights for a specific user, and one user can have only one right, but a table of rights can have many users.
I consider such a one-to-one relationship, do I think correctly and can be described in more detail what is what?
Thank you in advance, do not judge strictly!

  • Describe the structure of the tables. Perhaps because you misrepresent it, and there is a misunderstanding. - Ponio
  • Here it is not the case in the current tables, but in general how the connections work and how to understand. - El Salvadore
  • one
    It is not clear why you consider a one-to-one connection, if you yourself say before that the “rights table can have many users”. Read, for example, habrahabr.ru/post/193380 - Ponio

1 answer 1

You make one small mistake in your reasoning. It is necessary to take into account not the real, but the possible amount of user rights. Suppose a registered user has the right to create a topic, answer questions, comment on messages from other users. But someone offered him to become a moderator, and the integrity of the data could be immediately violated, as his previous rights did not disappear and new ones were added. Therefore, we need a table that will have an id_user, id_rule structure. A new rule is added, a new entry is created with the same id_user value, but another id_rule. If this is not foreseen, problems will begin.