in reply to Persistence framework for MySQL 4.x (InnoDB)

I have been using Class::DBI and Class::DBI::Sweet, but monks seem to be slowly gravitating towards the two modules that davorg recommends above as well as Rose::DB::Object that merlyn has recently recommended. Could you clarify two points for me, though:
  1. You shouldn't really have to use multiple-column primary keys, is there a particular reason for your design?
  2. You say referential integrity is important, but transactions are low priority. Why is that?
  • Comment on Re: Persistence framework for MySQL 4.x (InnoDB)

Replies are listed 'Best First'.
Re^2: Persistence framework for MySQL 4.x (InnoDB)
by mman (Novice) on Nov 01, 2006 at 13:56 UTC
    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.
      How about:
      BUG( id(pk), name ) LEG( id(pk), bug_id(fk), leg_number, length )
      and a unique index on (bug_id, leg_number)?
        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.
        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.