2017.02.16 06:32 AM
When you wish to resolve a foreign key – i.e., get the actual values instead of enumerated values – apply value
to the enumerated column.
q)meta update value eid from tdetailsc | t f a---| -----eid| j sc | j
Observe that there is no longer an entry in the f
column.
-----
What is the use of the above command?
Even without doing `meta update value eid from tdetails` I I can query `tdetails` using dot notation, e.g.: select eid.name, sc from tdetails and automatically get `name` merged in from the `kt`-table. This seems to be the same as after doing the above command.
I've read that enums and their underlying values are not the same (which makes perfect sense), but they behave the same in almost any context. So what's the use of explicitly translating enums to values using the above? Moreover, when changing anything about the enums (adding an enum for example) would I need to rerun this command?
Thanks,
Geert
2017.02.21 07:57 AM
There are a few reasons why you might want to resolve a foreign key:
1. You might want to persist the table to disk and not require the dependency on the other table (if you persisted the tdetails table without persisting the kt table in the same database then you’d have an un-resolvable column)
2. meta doesn’t tell the whole story as the types are very different:
q)type each flip tdetails
eid| 21
sc | 7
q)type each flip update value eid from tdetails
eid| 7
sc | 7
You might require type 7 for compatibility/consistency with something else.
Terry
EMEA
Tel: +44 (0)28 3025 2242
AMERICAS
Tel: +1 (212) 447 6700
APAC
Tel: +61 (0)2 9236 5700
KX. All Rights Reserved.
KX and kdb+ are registered trademarks of KX Systems, Inc., a subsidiary of FD Technologies plc.