wiki:UniqueElement

<unique>

A unique defines which properties of an entity (i.e., table columns) should be unique. There are two ways to make a field unique.

  1. A single column is unique. This example below shows that field "f1" is defined unique via unique="true". This means that there cannot be two entity instances - two rows in table entity1 - with the same value “x” in the f1 column.
    <molgenis name="example">       
      <entity name="entity1">
        <field name="f1" unique="true"/>    
        <field name="f2" />
        <field name="f3" />
      </entity>     
    </molgenis>
    
  2. A combination of two or more columns is unique. The example below shows that the combination of field “f1” and “f2” is defined as unique via the <unique> element. This means that there cannot be two entity instances - two rows in table entity1 - with the same value “x” in the f1 AND f2 column paired.
    <molgenis name="example">       
      <entity name="entity1">
        <field name="f1" /> 
        <field name="f2" />
        <field name="f3" />
        <unique fields="f1,f2"/>
      </entity>     
    </molgenis>
    

Required attributes

  • fields="field1,field2": comma separated enumeration of the unique fields.

No Optional attributes

No Child elements