Re: Foreign key problem
Date: Tue, 13 Jun 2006 08:21:25 -0400
> I am working on an application which need a data model that reflects
> the schema structure. My tables are ("*" indicates primary key column):
> columninfo(*table_name, *col_name)
> fk(*fk_name, pk_table, fk_table)
> fk_column(*fk_name, *fk_column, pk_column)
When an entry is made into FK, it establishes a foreign key but it also adds columns to the child table. The entry in FK signifies that the primary key columns from the parent table should become part of the structure of the child table, and should have RI to the parent table. Therefore you do not need to make entries into COLUMNINFO because the column definitions are *implicit* in the entry in FK.
The fourth table, TABFLAT, is a derived table that contains the flattened definitions of all tables. You must generate this table.
This approach allows us to have very tight definitions of tables. By convention we only make foreign keys to primary keys (not to other unique indexes), though others may wish to specify that a FK hits a different unique key on the parent table.
-- Kenneth Downs Secure Data Software, Inc. (Ken)nneth_at_(Sec)ure(Dat)a(.com)Received on Tue Jun 13 2006 - 14:21:25 CEST