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 8830449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:05:28+00:00 2026-06-14T08:05:28+00:00

I am currently designing a database with a role driven menu which has following

  • 0

I am currently designing a database with a role driven menu which has following requirements.

 1. Menu items can be assigned to a certain 'role'
 2. A role will be assigned to a user
 3. A user can have multiple roles

I have designed the database however I cannot map multiple roles to a single user in my current design. Also, I don’t understand how would I map the duplicate menu items (When a user is assigned multiple roles) while querying even if I include it in my design somehow.

I though about storing roles as comma separated values however that would further introduce complications.
Is their a better solution?
enter image description here

  • 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-06-14T08:05:29+00:00Added an answer on June 14, 2026 at 8:05 am

    C. Trimble is right (+1). If your menu items are available to multiple roles and your users can have multiple roles, then you actually have two many-to-many relationships that need to be recorded.

    That means that you need to add one more table, as below:

    ERD

    This table could have columns as per C. Trimble’s answer, or you could have a compound primary key of just UserId + RoleId – analogous to your MenuItemRoles table. The latter would be my design preference since the table is a pure intersection and there is no particular reason to expect that UserRoles would have children relating to it.

    Note that when you are retrieving user menu item access you can short-circuit the link from UserRoles to MenuItemRoles because they both have a RoleId column. This means you can join directly between the intersection tables, leaving Roles out of it. In TSQL it would look like:

    select I.*   -- Never select * in the real world.
    from MenuItem I
      inner join MenuItemRoles IR
      on I.ItemId = IR.ItemId
      inner join UserRoles UR
      on IR.RoleId = UR.RoleId
    where
      UR.UserId = @TheUserImLookingFor
    

    You could do the same thing in LINQ. If you’re using EF then you’re just going to have to go the long way around (through Roles).

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

Sidebar

Related Questions

I'm currently designing a database that has a table events that will be insert
I'm currently designing an application which I will ultimately want to move to Windows
I am currently designing a public-facing C++ API for a product which will require
I am currently in the process of designing myself a database driven website. The
I am currently in the process of designing a system which will use multiple
I am currently designing a class library that will provide data to a web
I am currently designing a role based authentication system for resources where many users
Currently I am designing a database for use in our company. We are using
I am currently designing a web application where I will have customers signing up
I am currently in the process of designing a database. I have a table

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.