FAQ

On 11/01/10 1:05 AM, George Stan wrote:
Hi,

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.

Hi George,

There is another option which I should have pointed out. Say you have an Attachments table. And an AttachmentsRelation table which is the many many join. Then make AttachmentsRelation a "single table inheritance" entity with children:

AttachmentsRelation_Contact
AttachmentsRelation_Room
AttachmentsRelation_Building
AttachmentsRelation_Painting

Then each of these children is mapped with a join in Cayenne modeler to the appropriate Contact, Room, etc entities. There will be a qualifier in the single table inheritance setup which will be something like "contact", "room", etc as needed.

That really should do everything you wanted.


Cheers
Ari



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

Search Discussions

Discussion Posts

Previous

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 11 of 11 | next ›
Discussion Overview
groupdev @
categoriescayenne
postedJan 10, '10 at 2:06p
activeJan 21, '10 at 9:18a
posts11
users5
websitecayenne.apache.org

People

Translate

site design / logo © 2021 Grokbase