Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 design help

Author  Topic 

mike123
Master Smack Fu Yak Hacker

1462 Posts

Posted - 2004-08-13 : 16:56:14

I have a table I'm creating that is going to represent access levels to the web app I am working on.

I have about 100,000 users, and about 10 of which will need special access. I've had it hardcoded in my .NET code before, but the 10 people is switching so much its time to move it to SQL Server (plus other reasons)

I'm not sure exactly what is the correct way to design this.

I was thinking of creating a table as such below, or would it be better to have 3 seperate tables. (1 for each access level)

userID, Level1, Level2, Level3

100, T, T, T
101, T, F, F
102, F, T, T
103, T, T, T
104, F, F, T
105, T, T, F
106, T, T, F
etc...



Any tips on this one is really helpful and greatly appreciated!

Thanks once again guys, have a great weekend !

mike123

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2004-08-13 : 16:58:33
userID
AccessLevel
Enabled

This is how I would build the table. You could also just store an XML string for each user that holds the permissions. You could then just pass that to the application on startup.

MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page

mike123
Master Smack Fu Yak Hacker

1462 Posts

Posted - 2004-08-13 : 17:02:41
your quick!

That design does seem alot better, it will make my inserts a bit trickier I believe, for users with multiple access levels etc..I'll figure it out tho.

thanks for the help!

mike123
Go to Top of Page

mike123
Master Smack Fu Yak Hacker

1462 Posts

Posted - 2004-08-13 : 17:15:16
Would it make more sense to have just userID and accessLevel ?

And only store the "True" values ?


Thanks again!

mike123
Go to Top of Page

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2004-08-13 : 17:20:53
That would also work. You could have an AccessLevel table with all the access listed. Then just have a UserAccess table with the UserID and AccessLevelID.

MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page

mike123
Master Smack Fu Yak Hacker

1462 Posts

Posted - 2004-08-13 : 17:24:09
Ya I'm only controlling access to 3 different pages, but there is no consistency between users with access to one page and access to another. So I will just do something like this

userID, pageAllowed

1000, 1
1000, 2
1000, 3
1001, 1
1002, 3
1003, 1
1003, 3





Thanks~!
mike123
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2004-08-15 : 07:49:05
I prefer Roles. I don't think I've ever had a "levels" soution that didn't have to be changed to "Can Bob at Level 4 also have access to PageX that is at Level 2 please ..."

So that would give you:

Roles Table - jsut a list of IDs and Descriptions

UserRoles - A list of UserID + Role

PageRoles - A list of PageID + Role

and then a user is allowed access to a page if they have a rolw that can be found in the Page Roles.

(In practice I cache the Roles for a user when they login - disadvantage is that they have to logoff if I need to add a new role for them)

Kristen
Go to Top of Page
   

- Advertisement -