Skip to content

Instantly share code, notes, and snippets.

@skilbjo
Last active February 4, 2022 21:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skilbjo/5bb9d7255c7f88544fe8ee3c7a29f5eb to your computer and use it in GitHub Desktop.
Save skilbjo/5bb9d7255c7f88544fe8ee3c7a29f5eb to your computer and use it in GitHub Desktop.

person table

id    | name | payroll_provider_id | company_id
------+------+---------------------+------------
[uuid]| john |        731273721    |    [uuid]

https://en.wikipedia.org/wiki/Natural_key A natural key (also known as business key[1] or domain key[2]) is a type of unique key in a database formed of attributes that exist and are used in the external world outside the database (i.e. in the business domain or domain of discourse)

https://en.wikipedia.org/wiki/Primary_key Informally, a primary key is "which attributes identify a record," and in simple cases constitute a single attribute: a unique ID

https://en.wikipedia.org/wiki/Foreign_key A foreign key is a set of attributes in a table that refers to the primary key of another table

https://en.wikipedia.org/wiki/Surrogate_key A surrogate key (or synthetic key, pseudokey, entity identifier, factless key, or technical key[citation needed]) in a database is a unique identifier for either an entity in the modeled world or an object in the database. The surrogate key is not derived from application data, unlike a natural (or business) key.

primary & surrogate key|      |      natural key    | foreign key
id                     | name | payroll_provider_id | company_id
-----------------------+------+---------------------+------------
[uuid]                 | john |        731273721    |    [uuid]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment