The SQL repository supports one-to-many relationships between two tables, and does not interpret the results according to any specific paradigm. This allows your application to apply whatever meaning you want to one-to-many relationships.
The SQL repository implements one-to-many relationships as multi-valued properties. To implement a multi-valued property, define the property with several <table> and <property> attributes:
<table> attributes
The <table>
tag for a multi-valued property must set the following attributes:
Attribute | Set To: |
---|---|
|
For example:
|
| The appropriate table column name. For example:
The |
| The appropriate table column names. As with auxiliary tables, the ordering of the ID column names is important. The columns specified by This attribute must list table columns in the same order as the |
<property> attributes
The <property>
tag for a multi-valued property sets the following attributes:
Attribute | Set To: |
---|---|
| One of the following:
For example:
|
| A primitive data type such as
Note that the SQL repository does not support references to binary types. |
| The item descriptor name of the referenced repository items. For example:
|
Note: You cannot establish a default value for multi-valued properties.
The following example shows how the XML repository definition might specify the multi-valued property interests
:
<item-descriptor name="user"> <table name="dps_user" id-column-names="id" type="primary"> <property name="login" data-type="string"/> </table> <table name="dps_interest" type="multi" id-column-names="id" multi-column-name="idx"> <property name="interests" column-name="interest" data-type="array" component-data-type="string"/> </table> </item-descriptor>
See also the Sample SQL Repository Definition Files section in the SQL Repository Reference chapter for more examples of one-to-many relationships in repository definitions.
Allow null values
By default, null values are not allowed in multi-valued properties. You can specify to allow null values at two levels:
Enable all multi-valued properties in a repository to accept null values by setting the repository property
allowNullValues
totrue
.Allow null values for an individual property by setting its
<property>
tag attributeallowNullValues
totrue
.