Gossamer Forum
Home : Products : DBMan SQL : Discussion :

Foreign Key Question for DBSQL2

Quote Reply
Foreign Key Question for DBSQL2
Hi Alex,

Is there any way to setup foreign key for the DBSQL2's table?

TheFox

Quote Reply
Re: Foreign Key Question for DBSQL2 In reply to
All you have to do is include the PRIMARY KEY column name from another table in the table where you want it to be the FOREIGN KEY...

Then configure that field/column in the new table to be UNIQUE.

EXAMPLE:

Table1

Table1ID (PRI)
Somecolumn
Someothercolumn

Table 2

Table2ID (PRI)
Table1ID (UNIQUE)
Somecolumn
Someothercolumn

And then if you have a 1->M connection, you should have an intersection table with concatnated key of the two PRIMARY keys from the two other tables...

Table3 (intersection)

Table1ID (UNIQUE)
Table2ID (UNIQUE)

Regards,

Eliot Lee