[eluser]OverZealous[/eluser]
[quote author="NachoF" date="1245956235"]which of those three fields would be primary key?[/quote]
In the DataMapper examples, the
id is always the primary key.
DataMapper doesn't actually use the relationship table
id column anywhere. It is only there for database design, to be used as the primary key. You are right that it is more
correct to set up the two foreign key columns as your primary key, and have foreign key restrictions.
I haven't done a lot of research into the side effects of using the FK columns instead of using the id column. If you decide to try it let me know how it works. I know one area that it could be an issue is when dealing with multiple relationships to the same objects, because you join table looks like this:
Code:
posts_users
=====================================================================
id | created_post_id | creator_id | edited_post_id | editor_id | ...
---+-----------------+------------+----------------+-----------+-----
1 | 1 | 2 | null | null |
2 | null | null | 1 | 4 |
So your primary key would then be
(created_post_id, creator_id, edited_post_id, editor_id).
In fact, if it proves that this works well, I would happily update the documentation and switch to using proper FK restrictions and multiple-column primary keys instead.