Thanks for reply.
1. Yes. I really need multicolumn primary keys, because I have such DB scheme and I think there's no way out. Suppose you have a bug with many legs: BUG(id(pk), name)---*LEG(bug_id(pk1), leg_number(pk2), length)
Is there another possible method to do such scheme? One-to-many relationship.
2. I'm using MySQL 4.x. Transactions is not too much concern me, cause I'll have only one SELECT'er and only one INSERT'er in my DB. Autocommit will satisfy me, I suppose. Maybe later I'll switch to MyISAM engine. Referental integrity is not to shoot myself in foot, while filling mapped structure and then saving it into DB. But I think relationships (many-to-one, one-to-may, one-to-one) is sufficient. | [reply] |
BUG( id(pk), name )
LEG( id(pk), bug_id(fk), leg_number, length )
and a unique index on (bug_id, leg_number)? | [reply] [d/l] |
Why would you ever want to access a leg in without the context of the bug that it comes from?
If you don't have a compelling reason to do so, and the leg is not used as the foreign key for another table, then there's no good reason to add the abstract key. You're never going to use it. Don't put it in there.
| [reply] |
I think there's redundancy: leg_number is natural key, and LEG(id) is abstract data. Why you don't like multicolumn pks? Because some frameworks not support them? Is it so hard to code it down? I've taked a took at DBIx::Class. I don't know it yet, but looks promising.
| [reply] |