문제

B2B Scenario I am trying is that:
The following Roles exists in the system:

  1. Super Admin
  2. Super Admin Staff
  3. Owner (client)
  4. Admin (owner i.e. client and creates admin to define sales counters)
  5. Sales Counters

That means there are users who'll create their own sub users e.g.
[FLAG-A] ROLE "SUPER ADMIN" creates a ROLE "Owner" and "OWNER" creates its own sub users ROLES i.e. "ADMN" & "SALES COUNTER".

Each role obviously has its info to login to the system

I tried to design database as following:

enter image description here

In this diagram I am assuming that main user creates sub user that in my view many to many relationship so I have to add table between them as "USER_PERSON".

Problem is to set "WHO CREATED USER" in the system. I mean which user has created sub user as described in [FLAG-A]
Please check this diagram enter image description here

도움이 되었습니까?

해결책

Your approach is unnecessarily complicated. Your situation boils down to this:

  • You have users (also persons), with their corresponding attributes, including login credentials and such, but also status and last login date.
  • A user (person) can have one (or more?) role(s).
  • A role has one or more permissions.
  • A user can be created by one other user, so the user's creator is among the user's attributes.

So, I'd model three entities:

  1. User (with all the properties), with a self-reference to the user's creator.
  2. Role, with a many-to-many relationship to User.
  3. Permission, with a many-to-one (or many-to-many) relationship to Role.

That's it.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 dba.stackexchange
scroll top