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

  • SEARCH
  • Home
  • 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 4079104
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T17:45:31+00:00 2026-05-20T17:45:31+00:00

I have userid and role id fields in the table. In that table couple

  • 0

I have userid and role id fields in the table. In that table couple userid’s has two roles. But it shouldn’t.

example:

Userid(FK)    RoleID(FK)
1             1E36A840-2EBB-44EC-8861-0E3D262AC676
1             0B54F223-E0D4-4CFC-84C3-7C98C1BFC6DA
2             1E36A840-2EBB-44EC-8861-0E3D262AC676
3             0B54F223-E0D4-4CFC-84C3-7C98C1BFC6DA
4             1E36A840-2EBB-44EC-8861-0E3D262AC676
4             0B54F223-E0D4-4CFC-84C3-7C98C1BFC6DA

In this case I have to delete 1 and 4 where ‘1E36A840-2EBB-44EC-8861-0E3D262AC676’ which has ‘0B54F223-E0D4-4CFC-84C3-7C98C1BFC6DA’

  • 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-20T17:45:32+00:00Added an answer on May 20, 2026 at 5:45 pm

    You can prevent this from happening in the first place by putting a unique constraint on the Userid column. However, before doing this you will need to remove existing duplicates. Given the information we have so far (a Userid and a Roleid) there’s really no way to “correctly” do this. As @Joe Stefanelli mentioned in his comment, you’d need to decide which role is the “correct” one for each user. That sounds like a manual process. (Unless you know ahead of time that only the first one should be kept in each case, in which case @Thomas has a good answer.)

    Out of curiosity, is there a specific reason why a user can’t (or shouldn’t, in this case) have multiple roles? Usually that’s what roles are for, applying multiple permission sets, etc. to various users in a many-to-many fashion. Think of it in terms of object-oriented design. Roles are interfaces (types) and users are classes (implementations). By having multiple roles, each user can be polymorphic into multiple user types throughout the system.

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

Sidebar

Related Questions

I have this databases: table<User>(UserID,Name,Surname,Username,Password,Email) , table<Role>(RoleID,RoleName,Description) , and table<UsersInRole>(UserID,RoleID) . I create a
I have a xml template like this <User> <UserId></UserId> <UserName></UserName> <Roles> <Role></Role> <Roles></Role> </Roles>
I have set up 2 two tables - table userid and table data in
I have the following database tables: Table1: User UserId Username Table2: Role RoleId Rolename
I have a few tables in my database User (userid, password roleid) Role (
I have the following db structure: User > UserRole < Role UserId UserRoleId RoleId
I have the following entities: User Role and then a join table: UsersRoles (UserId,
I have the following table UserID | User knows -------------------- a | b a
I have to insert roles for user by using check box but for inserting
I have complaint table 1. tblProfile with columns userId | name | age |

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.