- summary: PK to FK mapping sometimes misses a table? --> FK to PK mapping sometimes misses a table?
If there are multiple tables that have a particular foreign
key (FK) that map to a given table's primary key (PK)
the generated code is not complete.
Example in pubs database...
table 'pub_info', PK = 'pub_id'
table 'publishers', PK = 'pub_id'
table 'titles', PK = 'title_id', FK = 'pub_id'
which table should titles map to? currently the
generator finds the first table that has the PK matching
the FK, and assumes that it is the only one.
Where is this used? The standard templates business
objects contain properties of the type of each FK. This
is so the BLL user can type:
titles myTitle = titless[0];
publishers pubFK = myTitle.pub;
now they have a publisher object to work with, instead
of having to manually look up the appropriate publisher
object given the ID from the title object.
Problem: if the first table found during generation is
the 'pub_info' table, now they get a pub_info object
instead of a publisher object.
Solution?: Maybe the generator can find every other
table that contains a PK equal to the FK in titles. Then
generate a property for each type (pub_info and
publisher). In this case the default property name of
the FK field name minus the _id is no longer good, since
it would then generate two properties of the same name
and signature. The FK properties should be named the
same as the table the Pk comes from instead of the fk
fieldname. This may complicate the code that is auto-
generated to call these auto-generated properties?