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 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

This is the MySQL table structure that I have: itemID (BIGINT) userID (BIGINT) wasAdded
I have a submission table that is very simple: userId, submissionGuid I want to
I have a table User which has an identity column UserID , now what
I have a table UserAliases ( UserId, Alias ) with multiple aliases per user.
I have a postgres database with a user table (userid, firstname, lastname) and a
I have a DataTable that queries out something like below usergroupid...userid......username 1.............1...........John 1.............2...........Lisa 2.............3...........Nathan
So I have a database schema like this: Users UserId RoleUserXRef RoleUserId RoleId UserId
I have a database with one table, like so: UserID (int), MovieID (int), Rating
I have a script that appends some rows to a table. One of the
I have a model Question with a field called userid , before one ask

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.