Solved

Database Structure for User Perms

Posted on 2013-10-29
2
254 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

749 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