
19 Jan
2011
19 Jan
'11
1:57 p.m.
Hello folks Checkout this scenario Table 1 columns -> | table_1_id (pkey) | some_column | comments | Table 2 columns -> | table_2_id (pkey) | some_other_column | table_1_id (fkey) | comments | All primary keys are of type serial or auto number. The 3rd column on Table 2 is an fk that references Table 1's primary key. I would like to insert rows into both programmaticaly (from a c++ app) Do i have to insert to table one then SELECT-query the entry's primary key then insert the Table 2 row with the pkey result? Is there a more efficient way of handling this? Say using almost 2 queries? PS. A postgresql specific solution would also work