Re: Mapping fake FKs as relationships?

From: Aristedes Maniatis (ar..aniatis.org)
Date: Sun Jan 10 2010 - 17:21:19 EST

  • Next message: Aristedes Maniatis: "Re: Jira workflow"

    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.

    Ari

    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.
    >
    > Andrus
    >
    >
    > On Jan 10, 2010, at 4:05 PM, 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.
    >>
    >> Thanks in advance,
    >>
    >> George.

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



    This archive was generated by hypermail 2.0.0 : Sun Jan 10 2010 - 17:22:01 EST