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

  account id. Khatnam ----------------------- 1 | The first account   

... and then the child object should be allowed.

Pages

  PageID | PageName ------------------ 1 | First page   

control

  ControlID | ControlName ----------------------- 1 | First control   

menu

  menutime. MenuItemName ------------------------- 1 | Menu item 1   

I have permission table for reading / writing etc. ...

Permission

  permission id Permission name ------------------------------ 1 | CanRead 2 | Canwrite 3 | CanDelete   

So I'm trying to tie permission tables between multiple objects and child objects in several-to-many. Permission

  Account ID | Permission id Control ID | MenuItemID | PageID ------------------------------------------------- --------- 1 | 2 | Faucet Faucet Zero 2 Faucet 2 | Faucet NULL   

* This solution is just ugly.

The only account

A lot assigned to a table Menu Item ID < / Code> may be

PermissionAccountControl

  Account ID | Control ID | Permission id ------------------------------------ 1 | 1 | 1 1 | 2 | 1   

PermissionManuteM

  account ID | MenuItemID | Permission id ------------------------------------- 1 1 | 2 1 2 | 1   

Permission Page

  Account ID | PageID | Permission id --------------------------------- 1 1 | 3 1 2 | 1   

I am tilting towards two options

You can also use the Polymorphic Association

  + ------------ + ------------ + ---- ------ + ---------- ---- + | Account ID | Object type Object IDID | Permission id + ------------ + ------------ + ---------- + ------------ - + | 1 | Page | 1 | 1 | | 1 | Menu item | 1 | 2 | + ------------ + ------------ + ---------- + ------------ - +   

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.

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -