Solved

Database Structure for User Perms

Posted on 2013-10-29
2
255 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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MySQL Memory Keeps Increasing 4 95
restriction of entering a a page 5 44
Error in sql query statment. 21 70
Export Data from MySql Using PHP 16 67
Creating and Managing Databases with phpMyAdmin in cPanel.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

751 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