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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T03:12:20+00:00 2026-05-17T03:12:20+00:00

Is it better to have a single primary key, or use composite primary keys

  • 0

Is it better to have a single primary key, or use composite primary keys (usually, they are combination of one primary key and foriegn keys). I have examples below:

Composite Primary Key example:

AMeta

    — AMetaId – Primary Key
    — AMetaText

BMeta

    — BMetaId – Primary Key
    — AMetaID – Foreign Key to Table AMeta
    — BMetaText

A

    — AId – Primary Key
    — AMetaId – Primary Key and Foreign Key to Table AMeta
    — AText

B

    — BId – Primary Key
    — BMetaId – Primary Key Foreign Key to Table BMeta
    — AId – Primary Key and Foreign Key to Table A
    — BText

Single Primary Key example:

AMeta

    — AMetaId – Primary Key
    — AMetaText

BMeta

    — BMetaId – Primary Key
    — AMetaId – Foreign Key to Table AMeta
    — BMetaText

A

    — AId – Primary Key
    — AMetaId – Foreign Key to Table AMeta
    — AText

B

    — BId – Primary Key
    — BMetaId – Foreign Key to Table BMeta
    — AId – Foreign Key to Table A
    — BText

Which is the better Database Design?

  • 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-17T03:12:21+00:00Added an answer on May 17, 2026 at 3:12 am

    I genereally tend to use single-column primary keys almost exclusively – either there is a good natural key available (pretty rarely), or then I add a surrogate INT IDENTITY key to the table.

    My main reasons are:

    • the primary key needs to be unique, non-null at all times
    • the primary key is the clustering key in SQL Server by default, which adds stable (non-changing), narrow (4 bytes max.) and preferably ever-increasing to the list of criteria
    • with a single column primary key, all my foreign keys are also easy to use single columns – I don’t like having to join two tables on 3, 5 or even more columns just to get the join to work, which is exactly what happens if you have a compound primary key
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a fairly huge database with a master table with a single column
I have created the SQL script below that creates four tables and inserts data
I'm pretty new to databases and sql. I have a problem where I have
I have a database that contains a table that looks a bit like this:
I have a mid-size collection of records --about 20 million -- that I need
I have a product table with 100000 products and also I have a user
I have a table that has 5 columns: AcctId (int), Address1 (varchar), Address2 (varchar),
This is more of a correctness question. Say I have a table with a
I'm having some a little trouble understanding how to handle the database end of
I am having a tough time with this design problem and would appreciate any

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.