Skip to main content

Composite primary keys vs surrogate keys

  • March 10, 2018
  • 2 replies
  • 9 views

Bernard92
Forum|alt.badge.img+2

Hi all ,

One of our PS customer is wondering what is the best option ?
Using composite PK with 2 to 15 columns or using surrogate keys implying an extra additional join for each query (since the relation between the PK and the surrogate key will be defined in an extra table) ?

Regards
Bernard

2 replies

marcothesane
Forum|alt.badge.img+1
  • Participating Frequently
  • March 11, 2018

This is independent of the DBMS - and very true for Vertica, too:

Add a surrogate key to your table - and use the joins you mention to feed it, not to query it.


Bernard92
Forum|alt.badge.img+2
  • Author
  • Participating Frequently
  • March 12, 2018

Hi Marco , thanks for the answer , but could you elaborate a bit more ?
I am not too sure to understand what you mean with "use the joins to feed it, not to query it."
Regards
Bernard