Solved

Database Structure for User Perms

Posted on 2013-10-29
2
253 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
ID: 39609293
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
ID: 39614590
That'll work brilliantly, thank you so much!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

827 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