Welcome Guest! To enable all features please Login or Register.



How to work with composite keys
#1 Posted : Thursday, August 2, 2012 6:40:01 PM(UTC)

First thing you need to do when modeling a new object is to set up the object's key. The following guide describes how to set up a composite key for a primary object. If part of your composite key is essentially a reference to another object's key with the same field names, then you may also want to consider just making your object a child object of that other referenced object.

Here are the steps involved in defining a composite object key.
  1. First, you generally need to define a dedicated fieldset in the model for the key fields of your object, which you will not be able to use for any other object's composite key. The only exception to this rule is when your composite key needs to just reference the key of another already existing object, which typically happens either in child objects or when there is a 1-1 or 0-1 relationship between two objects.
  2. Add a fieldset element to the fields group element of your object.
  3. Set the ref attribute to the dedicated fieldset for your object key. If the key fieldset just references another object's key then set it to the dedicated fieldset for the referenced object's key.
  4. If the key values are entered/supplied by the user then set the key attribute to supplied.
  5. If the key is a reference to another object's key then set the key attribute to reference.
  6. Set the required attribute to true if the key fields cannot be null.
  7. Set the name attribute if your object may have another non-key reference to this fieldset or have fields with the same names as the fields in the fieldset.
  8. Provide a description of the key fieldset in its child element doc > summary as necessary.

Below is an example that demonstrates these steps.
<module xmlns="http://www.xomega.net/omodel">
    <fieldset name="car model key">
      <field name="make" type="string"/>
      <field name="model" type="string"/>
    <object name="car model">
        <fieldset ref="car model key" key="supplied">
            <summary>Car model composite key.</summary>
        <field name="release year" type="integer"/>
    <object name="car model details">
        <fieldset ref="car model key" key="reference">
            <summary>Car model composite key.</summary>
        <field name="body type" type="string"/>
        <field name="engine" type="integer"/>
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.