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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:56:18+00:00 2026-06-02T17:56:18+00:00

I have two tables, Table_1 with 4 columns (3 primary key) and Table_2 with

  • 0

I have two tables, Table_1 with 4 columns (3 primary key) and Table_2 with 2 column. When I try to create a foreign key constraint in Table_2, I am getting this error:

enter image description here

Here are the definitions of my tables:

Table_1

CREATE TABLE [dbo].[Table_1]
(
    [Field_1] [tinyint] NOT NULL,
    [Field_2] [tinyint] NOT NULL,
    [Field_3] [tinyint] NOT NULL,
    [Field_4] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
 CONSTRAINT [PK_Table_1] PRIMARY KEY CLUSTERED 
(
    [Field_1] ASC,
    [Field_2] ASC,
    [Field_3] ASC
)

Table_2

CREATE TABLE [dbo].[Table_2]
(
    [Field_1] [tinyint] NOT NULL,
    [Field_2] [tinyint] NOT NULL
) ON [PRIMARY]

Do you have any idea on how to solve this? 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-06-02T17:56:20+00:00Added an answer on June 2, 2026 at 5:56 pm

    The primary key of Table_1 is all three of Field_1, Field_2 and Field_3. In order to reference a key in another table, you have to reference all of the columns in that key – so you would need to add Field_2 and Field_3 to Table_2, and have all three columns included when you attempt to create the foreign key constraint.

    Alternatively, if Field_1, by itself, is a key for Table_1, then declare it as such, either by redefining the primary key, or adding a UNIQUE constraint on just Field_1 to Table_1. You would then be able to create the foreign key you’re attempting to.

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

Sidebar

Related Questions

I have two tables, each one has a primary ID column as key. I
I have two tables linked by a foreign key. Example: CREATE TABLE one (id
Lets say I have these two tables: CREATE TABLE nodes ( id INTEGER PRIMARY
I have two tables : T_STOCK : primary key is id , seller ,
I have two tables: <class name=Content table=language_content lazy=false> <composite-id> <key-property name=contentID column=contentID/> <key-property name=languageID
I have TWO tables 1) column 2) row COLUMN TABLE COLumnID ---------------- 1 2
I have a table with two columns: column A column B 1 2 1
I have two tables: table1, table2. Table1 has 10 columns, table2 has 2 columns.
I have to map two simple table with a foreign key relationship. One of
I have two dependent tables as CREATE TABLE posts ( post_id int(11) unsigned NOT

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.