Solved

Database Structure for User Perms

Posted on 2013-10-29
2
248 Views
Last Modified: 2013-10-31
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
Comment
Question by:t3chguy
2 Comments
 
LVL 1

Accepted Solution

by:
leason22 earned 500 total points
Comment Utility
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
 
LVL 1

Author Closing Comment

by:t3chguy
Comment Utility
That'll work brilliantly, thank you so much!
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction In this installment of my SQL tidbits, I will be looking at parsing Extensible Markup Language (XML) directly passed as string parameters to MySQL 5.1.5 or higher. These would be instances where LOAD_FILE (http://dev.mysql.com/doc/refm…
Foreword This is an old article.  Instead of using the MySQL extension that was used in the original code examples, please choose one of the currently supported database extensions instead.  More information is available here: MySQLi / PDO (http://…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now