CodeIgniter Forums
DataMapper ORM composite key handling - Printable Version

+- CodeIgniter Forums (
+-- Forum: Archived Discussions (
+--- Forum: Archived Development & Programming (
+--- Thread: DataMapper ORM composite key handling (/thread-48124.html)

DataMapper ORM composite key handling - El Forum - 01-05-2012

Essentially, I have a sales_orders table that has as its primary key the column names (account_id, acct_order_number). I need to have this because the acct_order_number may be the same from two different accounts. I then have a sales_order_items table that references the sales_orders table using the same two column names as the foreign key. What is the best practice for this with DataMapper ORM?

I currently have a sales_order_id column in my sales_order_items table (in addition to the foreign key fields) and I then run an update query that populates the sales_order_id based on records that match the foreign key fields in the sales_order table (for records where the sales_order_id field is null). These update queries take quite a long time; I am only doing this so that I can use the "simple" DataMapper key/relationship features. Ideally, I would like to map the foreign composite key directly to the related table.

Thank you for any help.

p.s. DataMapper ORM is awesome so far (I've only been using it a few days)!