in reply to Re: Class::Tables released
in thread Class::Tables released
Is there anyway that you could allow the user to choose the naming convention of the foreign key? For example, i would prefer to use the name "deparment_id" instead.Hmm, it seems like you are somehow seeing the old POD. Maybe your CPAN mirror has not gotten the latest (v0.23) that I uploaded about 6 hours before posting this announcement. In fact, an optional _id suffix is allowed on foreign and primary key column names now -- as well as intelligent matching with plural and singular column names and table names (using Lingua::EN::Inflect. Check out the POD on search.cpan.org (it's current there). In short, you can have a "departments" table and use "department_id" as a foreign key to it, etc.
but i haven't the foggiest clue how to cleanly implement/integrate that with what you have. A more valid gripe (i think) is to relax the condition that all tables must have a single primary key names 'id'. The reason is that a table like director_xref doesn't need it, instead it contains two primary keys (hence the suffix _xref). For example:Right, I've thought a lot about entities and relationships, but many-to-many (with a mapping table) is something I'm not quite sure how to do. As you say, the mapping tables need not have a primary key ID column. Also, you might have extra information in the mapping table, as in the track number in a song-to-CD mapping table:
Doing away with an additional primary key on the mapping table would be pretty tricky currently, but I'm open to suggestions. If it's any consolation your primary key doesn't have to be named just id anymore, it can be tablename_id, etc, same as for foreign keys.print $_->number, $_->song->name, $/ for $cd->tracks;
Anyway, thanks a lot for trying this out, and for your comments!
blokhead
|
|---|