Skip to main content
Post Closed as "Duplicate" by Tulains Córdova, CommunityBot, gnat, Bart van Ingen Schenau
added 1 character in body
Source Link
Loko
  • 197
  • 1
  • 9

What would be the most efficient way to store a users role(in my case) in the database?

What my user table looks like:

id int(AI) username varchar(80) password varchar(80255) 

For example the rights would be like this:

There should be rights to see a page:

  • Page1
  • Page2
  • Page3
  • Page4

So in the case above you should be allowed to either have the right to see Page1 and Page2 but also just Page3

You can

  • Delete post
  • Create post
  • Edit post

on just Page2

All these possibilities of combinations should have their own role.

Now I dont know how to store this in a table.

I thought about creating a table like this:

role | page1 | page2 | page3 | page4 | page5 | page6 | delete | create | edit | role1| yes | yes | no | no | no | no | yes | yes | yes | 

But I think there's way too many combinations to use this so there must be a better/efficient/easier way to do this.

So my question is:

What is the best/easiest way to do this?

What would be the most efficient way to store a users role(in my case) in the database?

What my user table looks like:

id int(AI) username varchar(80) password varchar(80) 

For example the rights would be like this:

There should be rights to see a page:

  • Page1
  • Page2
  • Page3
  • Page4

So in the case above you should be allowed to either have the right to see Page1 and Page2 but also just Page3

You can

  • Delete post
  • Create post
  • Edit post

on just Page2

All these possibilities of combinations should have their own role.

Now I dont know how to store this in a table.

I thought about creating a table like this:

role | page1 | page2 | page3 | page4 | page5 | page6 | delete | create | edit | role1| yes | yes | no | no | no | no | yes | yes | yes | 

But I think there's way too many combinations to use this so there must be a better/efficient/easier way to do this.

So my question is:

What is the best/easiest way to do this?

What would be the most efficient way to store a users role(in my case) in the database?

What my user table looks like:

id int(AI) username varchar(80) password varchar(255) 

For example the rights would be like this:

There should be rights to see a page:

  • Page1
  • Page2
  • Page3
  • Page4

So in the case above you should be allowed to either have the right to see Page1 and Page2 but also just Page3

You can

  • Delete post
  • Create post
  • Edit post

on just Page2

All these possibilities of combinations should have their own role.

Now I dont know how to store this in a table.

I thought about creating a table like this:

role | page1 | page2 | page3 | page4 | page5 | page6 | delete | create | edit | role1| yes | yes | no | no | no | no | yes | yes | yes | 

But I think there's way too many combinations to use this so there must be a better/efficient/easier way to do this.

So my question is:

What is the best/easiest way to do this?

Source Link
Loko
  • 197
  • 1
  • 9

User roles in database

What would be the most efficient way to store a users role(in my case) in the database?

What my user table looks like:

id int(AI) username varchar(80) password varchar(80) 

For example the rights would be like this:

There should be rights to see a page:

  • Page1
  • Page2
  • Page3
  • Page4

So in the case above you should be allowed to either have the right to see Page1 and Page2 but also just Page3

You can

  • Delete post
  • Create post
  • Edit post

on just Page2

All these possibilities of combinations should have their own role.

Now I dont know how to store this in a table.

I thought about creating a table like this:

role | page1 | page2 | page3 | page4 | page5 | page6 | delete | create | edit | role1| yes | yes | no | no | no | no | yes | yes | yes | 

But I think there's way too many combinations to use this so there must be a better/efficient/easier way to do this.

So my question is:

What is the best/easiest way to do this?