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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T00:37:12+00:00 2026-05-15T00:37:12+00:00

Can a compound key be set as a primary key to another table? For

  • 0

Can a compound key be set as a primary key to another table?

For instance i have the tables:

  • Books -with Primary Key:Product_ID
  • Client -with Primary key: Client_ID
  • Clients_Books -with Compound Primary Key:Product_Id and Client_ID

I want to set this compound Primary key from Clients_Books as a Primary Key to another table named: Order_Details. But I don’t want to use the Product_ID and the Client_ID from the Books, Clients tables.

Does this make sense? All opinions more than welcome.

  • 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-15T00:37:13+00:00Added an answer on May 15, 2026 at 12:37 am

    the short answer is, No – can’t do that. All of the columns in the PK (or other alternate key) must appear in the FK definition. Also remember that a table can have multiple keys – referred to as Candidate Keys (sometimes alternate keys). The primary key is simply the “best” key for your design/use (normally the narrowest one – smallest in byte size). We prefix the name of these other unique indices as “AK_{name}” – AK = Alternate Key.

    What we do under this circumstance is one of two things:

    1. define a synthesized PK being an “Identity” column, and then add a Unique Index to the compound key – thus having two “keys” on the table. All child tables then define the FK as pointing to the synthetic Identity PK column.
    2. Leave the compound key as is. Define it as the PK on that master table, and make all FKs have the same definition.

    Generally it isn’t a good idea to have multiple tables with the same PK definition (that is, PKs that are also FKs to another table). I say “generally” – it is important to understand the definition of your Entities.

    So why use #1? The question I ask myself is whether the compound key is really the data the defines the row? Is that compound key really THE definition of a row or is it more of an FK to some other data? If it is more of an FK then I create the synthesized PK(Identity). Is an Order really the books that a client owns? An order may cause a client to own a new book – but they may not be the same thing.

    Having the synthesized PK offers a few more choices down the road in future years. If the relationship needs to change in your Client_Books table then you might insulate changes to other tables.

    For instance – what if a customer can own more than one copy of a book – how will you implement that? With the synthesized key you could simply remove the Unique index on the compound-key and leave it as a simple FK, then the Order_Details table would simply represent when a customer purchased their second copy. If however you had taken the compound key on Orders route, then you’d have to figure out how to redefine Order_Detail as well as Client_Books (and any other FKs that pointed to Order_Detail).

    I would also ask you to evaluate whether an Order_Detail is really a Client_Book? Normally an Order causes the client to come into possession of a new book. I think of Orders as being independent of the inventory – therefore the PK on Order_Detail should not be the PK on Client_Books, Order_Detail should probably have it’s own independent PK.

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

Sidebar

Related Questions

How can you create models (and thus tables) with a compound (composite) primary/unique key
I have a table called Orderrow. Orderrow has a a compound primary key (CPK)
I have a database table which has a compound primary key (id_a, id_b) .
I have an Entity set that has Entities with a compound key containing ID
Is it posible to define a compound foreign primary key without defining scalar properties?
I have a database design that makes use of compound primary keys to ensure
The documentation says: If you have a compound index on multiple fields, you can
How can i combine two arrays in to a single array during compound selection
Can I order my users in the database, so I don't have to say
Can I change the field public virtual ClassOne ClassOne { get; set; } to

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.