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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T00:00:07+00:00 2026-06-06T00:00:07+00:00

What should the Primary key be in the Employee Table? Table Stores (PK) StoreID

  • 0

What should the Primary key be in the Employee Table?

Table Stores
(PK) StoreID
{other store columns}

Table Employee
StoreID
EmployeeID
{other employee columns...}

[Edit]
Our setup is such that an employee will always belong to one store only. Every employee should have a unique ID (ie, even if employees belong to different stores, they should never have the same ID).

I think the PK should be EmployeeID only, since it should ALWAYS be unique. My coworker thinks the PK should be compounded with StoreID+EmployeeID, but then it would be (theoretically) possible to have duplicate employee IDs. I don’t entirely follow his reasoning, but one thing he cited is performance. I am not too worried about query performance since for our database the Employee table has never exceeded 5000 records. We do have other, larger child tables that reference StoreID, is this a valid reason to create such a key?

[Edit]
Would the compound PK be okay if you also created an internal key that enforces uniqueness on only EmployeeID? Maybe there are multiple ways to do this, but I want to pick the most accepted practice.

  • 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-06T00:00:11+00:00Added an answer on June 6, 2026 at 12:00 am

    If your EmployeeID is unique across all stores, then it should be the primary key of that table. Like you said, otherwise you would have duplicate EmployeeIDs. The only reason I can see to have StoreID + EmployeeID is that if each store had its own employee numbers. If a person worked in two differnet stores, he would then need two EmployeeIDs, one for each store. From your question though, I don’t think that is the case.

    The StoreID should, however, be setup with a Foreign Key relationship, assuming that the employee will always be assigned a StoreID.

    Also, if your co-worker is mainly concerned with performance, you can add an EmployeeID, StoreID index to your table, that should clear up any slow queries (if you encounter any). Since you said the table was small, I would wait until a performance issue appeared before adding indexes. I think the primary key is always a logical organization decision, I wouldn’t consider performance as part of that decision.

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

Sidebar

Related Questions

I have two entities: Project, Employee Employee has primary key {employeeId} + some other
The scipt should subtract 1 from the primary key (auftrag_id) from a table. But
Possible Duplicate: Should each and every table have a primary key? If you never
Two tables in my database are as follows: [Employee] Table: Id (Primary Key, Autoincrement)
When should I consider representing the primary-key as classes ? Should we only represent
since a primary key (identifier) wont be under 0, i guess it should always
How should columns in a database table that have a PK/FK relationship be named?
I have table with following details Table name EMPLOYEE and columns EMPID (PK smallint
I have a EMPLOYEE table with EMP_ID,EMP_NAME,EMP_ADDRESS. EMP_ID should have the following format. EMP001
Is there any reason why I should not use an Integer as primary key

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.