Doubt with relation of tables - Modeling

Asked

Viewed 27 times

-1

Next guys, to with 3 tables here, I’m in doubt how to relate them.
I am studying relationship tables here... This project is a stock system, and has no intention, except to practice and study!
My doubt is the following, I have the table roles (functions), the table Categories (categories) and the table Permissions (permissions), I mean that each role will be allowed to read, edit and erase every record of Category.
What kind of relationship would that be?
Many For Many ? Would Use Table Permissions as a table pivot?
Thanks from now on who can contribute some explanation, this modeling business is driving me crazy..
Relacionamento

1 answer

0


I believe that among the table roles and the table Categories there is a relationship of many to many, that is a function can change several categories and a category can be changed by several functions, of course this will depend on the business rules of the application. This scenario I mentioned generates the need for an intermediate table between these other two. In this table should contain the foreign key of roles and of Categories, like you did in the pictures.

If your business rules allow only one function to read, edit or delete one or more categories we would have a relationship from one to many, in which case we would not need the table of Permissions. Since you could keep the foreign key of this roles inside the table Categories.

  • This is exactly what I intend to do, a function can change several categories, and a category can be changed by several functions. ai had created the Permissions table for it to be the pivot table. Vlw by explanation, I am studying about I get very confused.. I just wanted to get a second opinion.. Thank you very much.!

Browser other questions tagged

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