4
I am developing a permission system and I have a universe of 9 tables, which form the final permission for the user to use my systems, however, I am in doubt of how to build two of them, the "inherited" permissions of Systems and Groups, this means that when, for example, the user is a administrator, he has administrator permissions and, inherits, the permissions of user and visitor.
What I would like is to put together a structure that is easy to identify this and, most importantly, to manipulate, so follow the tables:
The table of Systems*:
CREATE TABLE [dbo].[Systems](
[Id] [int] IDENTITY(1,1) NOT NULL,
[Name] [varchar](50) NOT NULL,
The table of Groups*:
CREATE TABLE [dbo].[Groups](
[Id] [int] IDENTITY(1,1) NOT NULL,
[Name] [varchar](50) NOT NULL,
The Inherited System Permissions table**:
CREATE TABLE [dbo].[InheritingSystem](
[Id] [int] IDENTITY(1,1) NOT NULL,
[IdSystem] [int] NOT NULL,
[IdInheritedSystem] [int] NOT NULL,
The Group Inherited Permissions table**:
CREATE TABLE [dbo].[InheritingGroup](
[Id] [int] IDENTITY(1,1) NOT NULL,
[IdGroup] [int] NOT NULL,
[IdInheritedGroup] [int] NOT NULL,
*: I cut the rest of the CREATE TABLE
for brevity in the code.
**: These tables are under a strange name, I would like some other suggestion to them.
UPDATING
Explanation of the structure, the table of Systems and Groups are obvious, however, the table InheritingSystem
and InheritingGroup
are referring to the permissions inherited from their respective tables, therefore the IdSystem
and IdGroup
refer to System and Group, respectively, which has the highest permission, and the IdInheritedSystem
and IdInheritedGroup
are the Systems and Groups, respectively, which will complement the permission.
Data from the System table:
Data from the Group table:
Data from the Inherited Systems table:
Data from the Inherited Groups table:
I may be quite mistaken, but suggested names generate responses based on opinions
– Caputo
It’s not, but that’s just a small part of the question.
– BetaSystems - Rodrigo Duarte
@Caffé, could you check if the images appear for you, please? Here they do not appear.
– BetaSystems - Rodrigo Duarte
@Caffé, I explained better the functionality of this part.
– BetaSystems - Rodrigo Duarte
I think I get it. And where does the user come into this story? Is his table relevant to this question? You can get an idea of what you want, but you can not know the solution you have so far. Maybe you do not escape from posting the 9 tables.
– Caffé
So @Caffé, actually, I have no interest in leaving these 9 tables, even because, as far as I researched, this structure is the only structure that will suit me in this question and the user is not relevant to this issue, because my doubt revolves around the construction of tables
Herança
and their relationships, you understand?– BetaSystems - Rodrigo Duarte
Okay. Dealing only with what we have there, what it seems to me is that you want to create a group and add to it permissions of other existing groups; and the same for systems. I believe that this language is simpler and clearer than "inheritance". In this case, the tables would be:
GroupAddedGroups (Id, IdGroup, IdAddedGroup)
andSystemAddedSystems (Id, IdSystem, IdAddedSystem)
. Of courseId
in these tables is playing the role if surrogate key and can be dispensed with (depends on other design decisions). What do you think?– Caffé
@Caffé, carry this your comment for an answer, that I will mark it as correct. Another thing, you have some hint about modeling, apart from these two tables, in the general context, you think it’s good for the role you will play?
– BetaSystems - Rodrigo Duarte
You would have to see the other tables. There are many ways to set user permissions. But I don’t see anything wrong with what you’ve done so far (apart from the nomenclature you’re already improving). Maybe a good additional tip is: don’t plan a complex security system you’re not sure about right now that you’re going to need. On my way out, I’d make a system hard coded of groups, each user would belong to a group, and that’s it. If the customer wants more flexibility in the future, add more flexibility in the future.
– Caffé
@Caffé, I understand what you mean, but in this case, I already want to develop something complex, and "complete" now, not to have to rediscover in the future, since I already know I would have to perfect the code. But thanks for your help! :)
– BetaSystems - Rodrigo Duarte