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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T12:08:17+00:00 2026-06-03T12:08:17+00:00

I am using SQL Server Management Studio connected to SQL Server 2008 R2. I

  • 0

I am using SQL Server Management Studio connected to SQL Server 2008 R2.

  • I have a table called User with a column Id (uniqueidentifier)
  • I have a table called Role with a column Id (uniqueidentifier)
  • I want a table called UserRolePair with 2 columns: UserId and RoleId.

I need each row to be unique (no duplicate roles for each user).

This is easy – I just right-click, choose Indexes & Keys and create a new unique key, that is comprised of both columns.

Now what I need to do – is to create a foreign key from UserId to the Id column of the User table, and create a foreign key from RoleId to the Id column of the Role table.

But when I choose Relationships from the sub-menu – I get this:

this1

First of all – why do I have 2 relationships here ??

Second of all – when I want to create a new foreign key now for each column separately I get this:

this2

I can’t choose to RoleId the Id column of the Role table !

It says I need to assign both columns of UserRole table with foreign keys from the same table.

What is the solution ?

Is the ‘unique’ what’s causing my problems ?

  • 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-03T12:08:20+00:00Added an answer on June 3, 2026 at 12:08 pm

    Your best bet is to use T-SQL statements instead of struggling with the visual designers.

    a) create foreign key from UserRolePair to Role:

    ALTER TABLE dbo.UserRolePair
    ADD CONSTRAINT FK_UserRolePair_Role
    FOREIGN KEY (RoleID) REFERENCES dbo.Role(ID)
    

    b) create foreign key from UserRolePair to User:

    ALTER TABLE dbo.UserRolePair
    ADD CONSTRAINT FK_UserRolePair_User
    FOREIGN KEY (UserID) REFERENCES dbo.User(ID)
    

    Just execute those in a query window (make sure to be in the right database!) and you’re done!

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

Sidebar

Related Questions

Background: I'm using SQL Server Management Studio 2008 and I have a query window
I have a problem when debugging stored procedure using SQL server Management Studio 2008.
Im using SQL Server Management Studio 2008 (ssms.exe) connected with a local SQL Server
I'm using SQL Server Management Studio 2008 and SQL Server 2008. Currently, I cannot
using Visual.Web.Developer.2010.Express; using SQL.Server.Management.Studio.2008.R2; What I'm ultimately trying to do is update a sql
using Visual.Web.Developer.2010.Express; using SQL.Server.Management.Studio.2008.R2; Kinda new at C# here.. I got the first row
I am using SQL Server 2008 management studio to execute the following SQL statements,
I tried to turn on the Activity Monitor using SQL Server 2008 Management Studio
I'm using Microsoft SQL Server 2008 Management Studio to create a relational schema by
Is there any way to connect to MS SQL Server 2008 using Management Studio

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.