What do you do if you want to have the ID field have a meaningful name for your application?
Sometimes it comes to pass that when you're making a new table that you want to have the unique row identifier (a.k.a. IDKEY) to be a field that has a name that is meaningful for your data. Moreover, sometimes you want to set this value directly. Caché fully supports this functionality and it works Suppose you have a class Test.Kyle. The data will be stored like so:
Any other field can be unique, but the IDKEY is the one that is the subscript for all the data. There are two ways to create a named IDKEY.
- Property KyleID as %Integer [Identity];
- Property KyleID as %Integer;
Index IDKEYIndex on KyleID [IDKEY];
Number 1 works like the default IDKEY. It is not setable, and is automatically generated using $INCREMENT.
Number 2, on the other hand, is a property that you have to set manually (though you could give it an initial value). Moreover, the field being part of the IDKEY means it is inherantly required, though that keyword is never used.