Howto enforce a foreign key constraint on an already-existing table

Hi there,I just begin study Q and Kdb+ and now trapped by a problem.For an already-existing table, we know xkey operation can enforce aprimary key constraint. But what approach can we employ to achieve aforeign key constraint for the same table?Thanks in advance.Kind regards.

setup:q)t1:( a:abccbsnbcfox; b:til 4)q)t2:([b:til 4]; c: 4?1000)q)t1:a xkey t1q)t1a | b---| -abc| 0cbs| 1nbc| 2fox| 3enforce foreign key on column b in t1:q)update b:t2$b from `t1You basically replace column b with an enumeration over t2q)t1a | b—| -abc| 0cbs| 1nbc| 2fox| 3q)meta t1c| t f a-| ------a| sb| i t2q)select a,b,b.c from t1a b c---------abc 0 908cbs 1 360nbc 2 522fox 3 257On Jul 30, 10:56?am, more_more_tea <qshh…> wrote:> Hi there,>> I just begin study Q and Kdb+ and now trapped by a problem.>> For an already-existing table, we know xkey operation can enforce a> primary key constraint. But what approach can we employ to achieve a> foreign key constraint for the same table?>> Thanks in advance.>> Kind regards.</qshh…>