Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Best practice: multiple foreignKeys in one .ds.xml field

    Hi Isomorphic,

    what is the suggested approach if I have a field that links to many fields via foreignKey?
    I'd link to establish a link between the DataSources in order to includeFrom this DS into many other DS.

    I can't have
    Code:
    foreignKey="DS1.PK" foreignKey="DS2.PK"
    in my .ds.xml, because this is invalid XML.

    Code:
    <field name="name" type="integer">
        <foreignKey>DS1.PK</foreignKey>
        <foreignKey>DS2.PK</foreignKey>
    </field>
    does not work either (...cannot be cast to java.lang.String). Is this supposed to work?

    What is the suggested approach here? The last (dirty) solution I could think of are two (or more) different fields all pointing to the same db-field with nativeName and each with one foreignKey-attribute.

    Best regards
    Blama

    #2
    Multiple foreignKeys on a field are not supported. Can you explain what you're trying to achieve at a high level (both the user-interface you're putting together and perhaps describing the database table structure you're querying and what you want your records to ultimately look like)
    Thanks

    Comment


      #3
      Hi Isomorphic,

      I have a DataSource with all the detail fields for the objects I'm administrating in my app. This DS is not used directly. Let's call it MANAGEMENT.

      I have many different DataSources inheriting fields from this DS and adding some includeFrom-fields (named e.g. INCREATION, READY, INPROGRESS, CLOSED). (The fieldlist is LONG and I don't want to repeat the fields and keep the settings in sync.) These different DataSources then filter on status in the <whereClause>.

      I don't have these includeFrom-fields on the MANAGEMENT DataSource as the joins for these fields go to expensive DETAIL-views and I don't need these fields in all status from above.

      I could join from the ID-field in DETAIL, but this only works if the DETAIL-DataSource is only needed in one of INCREATION, READY etc, which I do so far. But now I need the detail in more than on of these.
      I can't foreignKey from MANAGEMENT, as the ID-field here already has a foreignKey-attribute. Also I have many DETAIL-views.

      Best would be if I could enter many foreignKey in the DETAIL-DataSource. If that is not possible I'd try this approach:
      Code:
      <field name="ID" foreignKey="INCREATION.ID" />
      <field name="ID2" nativeName="ID" foreignKey="READY.ID" />
      What is your suggestion here?

      Best regards
      Blama

      Comment


        #4
        I think your "dirty" solution is not so dirty. That seems like a reasonable way to model what you have set up. Alternatively, you could declare the foreignKey relationship form the DETAIL DataSource back to MANAGEMENT. The relational join code is intelligent enough to figure this out.

        Comment


          #5
          Users finding this thread via search: My proposed solution is not correct, use customSelectExpression instead. See this thread.

          Best regards
          Blama

          Comment


            #6
            Users finding this thread via search: It seems this will be supported in 13.0 (sample, docs).

            Pretty cool, Isomorphic !

            Comment

            Working...
            X