From
http://search.cpan.org/~grichter/DBIx-Recordset-0.24/Recordset.pm#Automatic_detection_of_links

We have::

DBIx::Recordset and DBIx::Database will try to automatically detect links between tables based on the field and table names. For this feature to work, the field which points to another table must consist of the table name and the field name of the destination joined together with an underscore (as in the above example name.street_id). Then it will automatically recognized as a pointer to street.id.

My comments:

Table linkage detection is a useful feature. However, whenever we must use SQL, the easiest way to join two tables is via a NATURAL join, in which case, both tables would have the field named
street_id. In one case it is the primary key and in another it is the foreign key, allowing:


SELECT *
FROM street
   NATURAL INNER JOIN f

instead of

SELECT *
FROM street
   INNER JOIN f ON street.id = f.street_id

So, why is it preferable to have different names for foreign and primary keys if the most succinct SQL can be generated from them having the same name?




--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to