Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top


There is a table users with autoincrement primary key id.

There is also a table employees (every employee is a user but not vice versa). The employees primary key is userid. The field userid is not autoincrement.

employees.userid is a foreign key for

Thus every employee's primary key value is also users primary key value.

Now consider a third table rows of which should refer to an employee.

The question: Should the third table refer to or to employees.userid?

share|improve this question
You say "Now consider a third table rows of which should refer to an employee." – ypercubeᵀᴹ Apr 25 '13 at 14:52
up vote 2 down vote accepted

If the third table is related to employees and not to every user, you should reference employees.userid.

It makes sense for, say, a table of employee identity card numbers to reference "employees"."userid". But it makes sense for a table of email addresses to reference "users"."userid", because every user has an email address.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.