https://learninghub.kx.com/forums/topic/linked-columns-and-overloads-of
I am trying to figure out WHICH overloads of $ ! ? are used in foreign keys and linked columns syntax
Foreign Keys
kt$localColumn
Question 1. Is $ for enum ?
Question 2. kt as a table type is undocumented (but implied) right ?
LinkedColumn
otherTable!otherTable.otherCol?localColumn
Q3. Is ? doing a find
Q4. Is ! doing a dict (as in keyed table is a dict too) way OR "linking" which is undocumented still
Q doc still has some gaps which is why I have come up with these inferences after playing around with the code in the links below for a while. So ideally please gives "yes"/"no" or a big tutorial ;-)
Links
https://code.kx.com/q/kb/linking-columns/#splayed-tables
https://code.kx.com/q/wp/foreign-keys/#foreign-keys
The following page has some examples on the different types of enum operations: https://code.kx.com/q/basics/enumerations/
Q1. Yes, $
is creating an enum. https://code.kx.com/q/ref/enumerate/ . Could you supply a reproducible case for what the variables represent in the first statement.
Q2. KeyedTable (kt?) is documented see https://code.kx.com/q/kb/faq/#keyed-tables.
Q3. ?
is doing a find. https://code.kx.com/q/ref/find/
t1
c1 c2
c 10
b 20
a 30
c3
sym$
ab
a`c
t1.c1?c3
2 1 2 0
Q4. The !
is simply creating an enumeration. If you are then to update the table with the result of that query, it would be added to the table as a foreign key. Documentation exists here. https://code.kx.com/q/ref/enumeration/
`t1!t1.c1?c3
`t1!2 1 2 0
update link:t1!t1.c1?c3 from
t2
`t2
meta t2
c | t f a
----| ------
c3 | s
c4 | f
link| j t1
The following page has some examples on the different types of enum operations: https://code.kx.com/q/basics/enumerations/