Content-Disposition: inline Hello,
I have the following:
q) S1:([SC_ID:()]SC_NAME:())
q) I1:([IN_ID:()]IN_NAME:() ;IN_SC_ID:())
q)meta I1
c |
t f a |
IN_ID |
s |
IN_NAME |
C |
IN_SC_ID |
s |
q)meta S1 |
|
c |
t f a |
------- |
----- |
SC_ID |
s |
SC_NAME |
C |
I now want to set the IN_SC_ID of I1 as a foreign key: S1’s primary key SC_ID.
Typical definition for an empty table could have been
q) I1:([IN_ID:()]IN_NAME:() ;IN_SC_ID:`S1$())
Is it possible to set the foreign key _after_ I1 & S1 have been filled? Or should it be part of the schema definition?
(Assuming that the values are available and there are no errors in the data)
Regards,
Yuva
A foreign key is just a definition of a tie from a column in one tableand its possible usage as a the key into another table (whether simpleor compound). So yes you can apply it after the table has been createdif you like by a simple cast.An example with a tables q and t (note the f setting of q after thecast):q)t:([sym:10#a
bc] val:til 10)q)meta tc | t f a---| -----sym| sval| iq)q:([] sym:10#
ab
c; val:til 10)q)meta qc | t f a—| -----sym| sval| iq)q[sym]:
t$q[sym]q)meta qc | t f a---| -----sym| s tval| iOn 5 Dec, 00:56, "Yuvaraj Athur Raghuvir" <yuvaraj....>wrote:> Hello,>> I have the following:> q) S1:([SC_ID:()]SC_NAME:())> q) I1:([IN_ID:()]IN_NAME:() ;IN_SC_ID:())> q)meta I1> c ? ? ? | t f a> --------| -----> IN_ID ? | s> IN_NAME | C> IN_SC_ID| s> q)meta S1> c ? ? ?| t f a> -------| -----> SC_ID ?| s> SC_NAME| C>> I now want to set the IN_SC_ID of I1 as a foreign key: S1's primary key> SC_ID.>> Typical definition for an empty table could have been> q) I1:([IN_ID:()]IN_NAME:() ;IN_SC_ID:
S1$())>> Is it possible to set the foreign key after I1 & S1 have been filled? Or> should it be part of the schema definition?>> (Assuming that the values are available and there are no errors in the data)>> Regards,> Yuva</yuvaraj…>