I am already using that and it works indeed, my question was though for when your foreign key is composite. If the parent table has a primary key formed of 2 columns, how do insert values in a child table via c#? Are you implying that inserting the 2 columns separately as arrays should work?
While inserting from C#, simply using 2 columns to store foreign key values won’t work. You can use additional q function which takes care of enumerating the foreign key values over a parent table:
c.k("{[x;y;z] x insert (enlist y$first z),1_z}", "tdetails", "ktc", new object[] { new object[] { "Prefect", "Ford" }, 133, 2 });c.k("{[x;y;z] x insert (enlist y$first z),1_z}", "tdetails", "ktc", new object[] { new object[] { new string[] { "Prefect", "Ford" }, new string[] { "Prefect", "Ford" } }, new int[] { 156, 33 }, new int[] { 1, 2 } });
That example was very useful for me to learn more of q, thanks.
But when you have a table that has 10 composite foreign keys like that, I guess it will end up pretty ugly. This is external data shaped like that, which I am trying to bring into q, as a learning exercise at this stage.
Unless somebody has some better idea, I am thinking to insert the data first as pairs of symbols and then cast it to the parent table type by doing something like this:
Maciej, I gave qSharp a shot and I find out it outperforms kx c# interface. Thanks for pointing me to it.
One thing which I would hold as a minor bug though. While you can have columns with a runtime type of ‘type’, if you declare column with a compile time of say char, qSharp throws an exception saying it’s not able to handle char types. You are forced to use object type for that. kx’s c class doesn’t have that problem.
On Saturday, March 21, 2015 at 10:20:18 AM UTC+1, Greg Borota wrote:
Maciej, I gave qSharp a shot and I find out it outperforms kx c# interface. Thanks for pointing me to it.
One thing which I would hold as a minor bug though. While you can have columns with a runtime type of ‘type’, if you declare column with a compile time of say char, qSharp throws an exception saying it’s not able to handle char types. You are forced to use object type for that. kx’s c class doesn’t have that problem.