title: Entity Framework : Relational Model help for Permissions, Users etc
body: <p>Can anyone help?</p>
  
  <p>I am looking to create a good relational model for managing Permissions.</p>
  
  <p>I currently have a Users table, and various other tables like Customers, Suppliers.</p>
  
  <p>The user needs permissions to View, Edit, Create in either Customers, Suppliers.</p>
  
  <p>I will use these tables in EF to decide what access a user has and weather to show a form or not etc.</p>
  
  <p>My original model goes like this, although i think its wrong, as it dosn't state anything about Permissions.</p>
  
  <p>Users
  UsersCustomers (contains relation between Users and Customers)
  UsersSuppliers (contains relation between Users and Suppliers)
  Customers (customer table)
  Suppliers (suppliers table).</p>
  
  <p>Although this works, i.e. it relates a user to a Customer for example... It just doesn't seem right.</p>
  
  <p>I was thinking of putting a intermediate table called Permissions which woul have a Id and a UserId that would link the user table. Then i could link Permissions to a table like</p>
  
  <p>PermissionsCustomers (in place of UsersCustomers) that would contain a relation between the persmission and customers.</p>
  
  <p>I think this where i am not quite getting an optimum design. Once this design is correct it would be also missing a table to assign what type of permission a user has to a Customer i.e. Edit, Create or only view etc.</p>
  
  <p>I would love to hear some feedback or an example of a strong model that exists that functions like this.</p>
  
  <p>With regards to the customers, suppliers, these are just 2 examples, there will be lots more tables like deliveryLocation, accountsLedger etc.</p>
  
  <p>It would be great if i could do a query that said "Show me all permissions that user X has", currently with my setup i would have to query each Intermediate table separately.</p>
  
  <p>I would be using this via an ORM like entity framework.</p>
  
  <p>A little lost with the structure of the relational model.</p>
  
  <p>Thanks in advance.</p>