Having actually done this the first way Andrus mentions, my advice is to do it the second way (as an inheritance) if you can. The first way is pretty easy, but you don't end up with actual SQL JOIN statements when (say) you try to find all records Tagged with a certain tag. You end up with very long SELECT IN.... across the join. Which works fine until you try to join 10,000 records.

George, could you point us to the documentation for how ActiveRecord implements this? I'd be interested in their approach.


On 11/01/10 1:35 AM, Andrus Adamchik wrote:
Not directly, but you can emulate that with entity qualifiers by
filtering the generic entity on the value of the column that is not
participating in a join. You can even map that as an inheritance hierarchy.


On Jan 10, 2010, at 4:05 PM, George Stan wrote:

Is it possible to map fake foreign keys with CM?

In many DBs for webapps there seem to be quite a few tables (for
entities like Tags, Comments, Attachments, Events) to have
relationships to many other tables, and instead of a FK, a combination
of two fields is used (target_table_name and target_row_id).

I know that other ORMs (like ActiveRecord from RoR) have this feature,
but I'm not sure about Cayenne.

Thanks in advance,

Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C 5EFA EF6A 7D2E 3E49 102A

Search Discussions

Discussion Posts


Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 3 of 11 | next ›
Discussion Overview
groupdev @
postedJan 10, '10 at 2:06p
activeJan 21, '10 at 9:18a



site design / logo © 2021 Grokbase