SQL Server database design: Advice on many to many relationship -
I am setting up a database and in one place where I am confusing myself in many different tables I am I am looking for some advice in the best way of designing it for performance and scalability.
I will put an example of my establishment and I am trying to lower it.
I have the main object table ...
account ... and then the child object should be allowed. Pages control menu I have permission table for reading / writing etc. ... Permission So I'm trying to tie permission tables between multiple objects and child objects in several-to-many. Permission * This solution is just ugly. The only account A lot assigned to a table PermissionAccountControl PermissionManuteM Permission Page I am tilting towards two options You can also use the Polymorphic Association This method may be useful if you need to manage permissions for additional objects in your software later in the day if you use this table structure You will not need to create new tables or add new columns to existing tables.
account id. Khatnam ----------------------- 1 | The first account
PageID | PageName ------------------ 1 | First page
ControlID | ControlName ----------------------- 1 | First control
menutime. MenuItemName ------------------------- 1 | Menu item 1
permission id Permission name ------------------------------ 1 | CanRead 2 | Canwrite 3 | CanDelete
Account ID | Permission id Control ID | MenuItemID | PageID ------------------------------------------------- --------- 1 | 2 | Faucet Faucet Zero 2 Faucet 2 | Faucet NULL
Menu Item ID < / Code> may be
Account ID | Control ID | Permission id ------------------------------------ 1 | 1 | 1 1 | 2 | 1
account ID | MenuItemID | Permission id ------------------------------------- 1 1 | 2 1 2 | 1
Account ID | PageID | Permission id --------------------------------- 1 1 | 3 1 2 | 1
+ ------------ + ------------ + ---- ------ + ---------- ---- + | Account ID | Object type Object IDID | Permission id + ------------ + ------------ + ---------- + ------------ - + | 1 | Page | 1 | 1 | | 1 | Menu item | 1 | 2 | + ------------ + ------------ + ---------- + ------------ - +
Comments
Post a Comment