Skip to main content

Questions tagged [surrogate-keys]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
18 votes
3 answers
8k views

Are surrogate keys a known anti-pattern?

My workplace's database has a pattern that I've not seen before. Every column that is intended to be a key, whether primary or foreign, ends in _SK. This is shorthand for "surrogate key". It ...
J. Mini's user avatar
  • 1,017
0 votes
2 answers
93 views

Is it a good idea to let database surrogate key values spill out into other aspects of code (HTML, Controllers, Model, Repository layer)?

Is it acceptable to use id in HTML forms and subsequent code processing (controller, view, model, repository layers)? For example I need to show something like this on a web page: Select Motor ...
Dennis's user avatar
  • 8,247
3 votes
2 answers
407 views

Is it acceptable to use a surrogate key identifier as a URL parameter?

Example: in the database I have a record such as this: { id: 53, part_number: 'MOTOR-OIL', description: 'Motor Oil' } I wish to use a link that displays this record. I could refer to ...
Dennis's user avatar
  • 8,247
0 votes
1 answer
105 views

CRM and external systems: How to associate data with contacts?

This question is about Dynamics CRM but is valid for every system that allows merging entities. Having data related to a contact in multiple external systems, how would you know which contact the ...
Jan Sommer's user avatar
5 votes
3 answers
440 views

How to avoid mixing surrogate key with the rest of the data

Suppose you have a very simple CRUD where you are just storing a simple tuple-like type of data, but its natural primary key is cumbersome for the user to remember (very long, difficult to write, etc.)...
Randy Eels's user avatar
3 votes
3 answers
3k views

Is is OK to use a non-primary key as the id in a rails resource?

I am getting ready to set up a resource for some new api calls to my rails application. I am planning on calling the resource devices ie resources :devices This is going to represent android mobile ...
nPn's user avatar
  • 149
9 votes
2 answers
746 views

Is there a canonical source supporting "all-surrogates"?

Background The "all-PK-must-be-surrogates" approach is not present in Codd's Relational Model or any SQL Standard (ANSI, ISO or other). Canonical books seems to elude this restrictions too. Oracle'...
Tulains Córdova's user avatar
14 votes
9 answers
5k views

Should a surrogate key ever be exposed to a user?

Often in a table that has no natural key, it is still useful for users to be able to have a uniquely generated identifier. If the table has a surrogate primary key (and in such a case you would ...
psr's user avatar
  • 12.9k
12 votes
4 answers
1k views

Do these specific tables need surrogate keys?

Background I have this tables +-------------------------+ +------------------------+ |Airport | |Country | |-------------------------| |------------------------| |...
Tulains Córdova's user avatar