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

Suppose we are creating databases containing information about monkeys, and a user interface to present monkey information to users.

We have two separate databases. The schemas are identical (and are at least intended to remain so) but they are on different machines and have information on different monkeys. This is inconvenient but unavoidable.

The user interface we're building queries both databases and presents all the monkeys in the same filterable HTML table to the user.

What's the best approach to generating IDs for monkeys? Is it acceptable to prefix the ID according to which database the monkeys are in?

share|improve this question
Which database? Same LAN? Are you querying both databases in a live manner? In short, more detail, please! – Max Vernon Oct 7 '13 at 3:03
up vote 2 down vote accepted

I'd consider composite PK instead of prefixing values in one column. It seems a bit more clear to me, and it should help avoiding potential problems if you switch to single server (or cluster) in the future (then this column can be used as partition key).

share|improve this answer

Does your ID have to be numeric? If not you could use a uniqueidentifier field.

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.