Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 262
  • Last Modified:

Database Structure for User Perms

I am working on redesigning my corporate intranet, and need some guidance as to a good table layout for the user permission scheme below:

- Have a table of users each containing a user id.

- Assign each application a unique Id.

- Assign each user permissions to the application ID's that they would need.

- Create a functions table that would hold function names, such as canEdit, canConvert,  canDelete, etc.

- Assign each user access to the functions they would need by either a 1 or a 0 value in the database table.

Wondering the best way to structure these tables for the best speed and performance, as well as management.

Thanks in advance!
0
t3chguy
Asked:
t3chguy
1 Solution
 
leason22Commented:
Using 1 and 0's has it's place, but a friendlier method by today's standard is to use the primary key 'id' columns for each table.

First off :Here is an excellent website full of example schemas.
http://www.databaseanswers.org/data_models/index.htm

Secondly, using 1's and 0's can become really unfriendly later. Keep to well labeled column names, following some kind of convention. For example, create two entity (or noun) tables:  tblUser, tblApp.
Create a primary key in each table (tblUser.userid , tblApp.appid).

Create one transaction (verb) table: tblUser_App.
Create two foreign keys columns. One each to relate to each entity table.
(1)tblUser_App.userid, (2) tblUser_App.Appid .
You should end up with one distinct row for each user in tblUser, along with one distinct row for each app, or app event in tblApp.
This is to conform to best normalization.
But, there will be redundant rows for userid in tblUser_App, in other words, one for every app that the user will have rights too.

Then, index these columns for fastest performance.
On top of that, later you can create views or stored procedures for your queries to really speed up query times.

One more tip to design, notate the key words of SQL, and AVOID using those in any names of tables, columns, etc.
0
 
t3chguyAuthor Commented:
That'll work brilliantly, thank you so much!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now