Question
· Feb 7, 2018

What is the difference between IDKEY and Primary Key of a SQL table

My question is actually about IDKEY since Primary Key is the common concept of SQL.

Why do we need IDKEY? In what kind of scenario, the IDKEY would be different from Primary Key?

Thanks.

Discussion (2)0
Log in or sign up to continue

In Caché you typically work on objects but you can present them also as rows in an SQLtable.
The identifier for objects is IDKEY if you don't do it yourself it is assigned by Caché.
PrimaryKey is something you assign by your application.

Both are UNIQUE.
And if you define your PrimaryKey as Autoincrement  starting with 1 both are quite likely identical.

That's a basic view. IDKEY has far more variants to be found in documentation.

In what context are you encountering IDKEY?

While Primary Key, ID  and IDKEY refer to the same concept, there are some nuances:

  • Primary Key - is something that uniquely identifies a row or an object (it's usually a property or several properties)
  • ID is a default name of the Primary Key property (persistent cache classes/tables have ID property by default and it's a Primary Key) 
  • IDKEY is an index over Primary Key property (regardless of the actual property name)