User permission table structure

Hi,

I have a PHP script with many restricted areas. In each of these areas I have a function that checks if the user have access to the current area by checking the “usergroup” table. That problem is I have over 100 columns now so I’m not sure if that’s a correct database design.

Please advise. Thanks.

the “current areas” should each have a separate row in a one-to-many table

having 100 columns is a pretty sure sign that the table isn’t in first normal form

Hi Rudy,

I’m a little bit lost. Each user may belong to more than one usergroup so my current structure looks like this:

user

-> userid
-> usergroupid
-> username
-> pass…

usergroup

-> usergroupid
-> title
-> zone1
-> zone2
-> zone…

How should it look in your way?

Thanks.

usergroup
-> usergroupid
-> title

user
-> userid
-> usergroupid
-> username
-> pass…

usergroup_zones
-> usergroupid
-> zone

:slight_smile:

Thanks, I’ll try that :slight_smile: