Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 307677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T07:34:49+00:00 2026-05-12T07:34:49+00:00

I am slightly confused on how to setup my table. I have three roles

  • 0

I am slightly confused on how to setup my table. I have three roles which can be selected through checkbox. While registration…. if user selects one and two… then those pages should be visible, if he selected one and three then those pages and if selects anyone of them then those alone…

Let us name the page 1 as client management
Page 2 Invoice Management
Page 3 View report

Should i have seperate fields for these three or one is enough.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T07:34:50+00:00Added an answer on May 12, 2026 at 7:34 am

    Keeping separate fields for each roles is not a good idea. If you would want to add another role you will need to update your database structure.

    You can do two things IMO:

    SET field

    Create an set field where you can define any roles the user have in just one value, this will still require ALTERing the table if you want to add a new role but at least it won’t add another field to the table

    M:M table

    Create M:M (many to many) table that will connect roles with users, this solution doesn’t require changing the db if you want to add another role

    CREATE TABLE `users` (
        id INT AUTO INCREMENT,
        login VARCHAR(100) NOT NULL,
        password CHAR(32) NOT NULL,
        PRIMARY KEY (id)
    )
    
    CREATE TABLE `roles` (
        id INT AUTO INCREMENT,
        name VARCHAR(50) NOT NULL,
        PRIMARY KEY (id)
    )
    
    CREATE TABLE `user_roles` (
        user_id INT,
        role_id INT
    )
    

    I would also add constraint to the user roles table that will make sure that correct ids are in that table but I won’t add them in that example to just keep it simple. More details on that you can find here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm slightly confused with template specialization. I have classes Vector2 , Vector3 which have
This answer had me slightly confused. What is a 'select to a temp table'
I get a compile error, which I'm slightly confused about. This is on VS2003.
i am slightly confused about how jquery's Delegate Function works. If I have a
I have always been slightly confused with the amount of different IO implementations in
I was slightly confused when, looking through some of the more obscure implementation code
I've enabled Roles in my ASP.NET web application, but I'm slightly confused as to
I have a URI here in which a simple document.cookie query through the console
I have been working with Entity Framework 4 recently, and am slightly confused as
I am working through Chris Pine's Ruby book, and I am slightly confused why

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.