...
The following demonstrates in more detail the example where properties from an existing "country
" domain domain is to be referenced by a new domain called "students
". Assume the "country
" domain domain contains many properties including the country " name " and the address for the immigration office. The "students" domain student
domain will reference the "countries
" domain twice 1) domain twice:
- In a property called
...
-
homeCountry
- A property called
immigrationAddress
GET the
...
address
...
Property in the
...
countries
...
Model Schema
GET /domains/country/properties?version=1
...
Code Block | ||
---|---|---|
| ||
[ { . . "propertyName": "immigrationAddress", "propertyType": "node", . . }, { . . "propertyName": "name", "propertyType": "string" . . } ] |
Add the Cross-Reference into the
...
students
...
Model Schema and POST a New Domain
POST /domains
Code Block |
---|
{ "name": "students", "modelSchema": { "properties": { "homeCountry": { "type": "uri", "uriType": "xref", "xrefLocation": "/mdr/country:v1/name" }, "immigrationAddress": { "type": "uri", "uriType": "xref", "xrefLocation": "/mdr/country:v1/immigrationAddress" }, . . . } } } |
Note that `homeCountry` is homeCountry
is a primitive type while `immigrationAddress` is immigrationAddress
is a node and contains several items such as street, city, province-state, postal-code.
Again, the "stuents" domain students
domain could just reference the "country
" MDR MDR once which would cause the entire "country
" MDR MDR to be inserted.
How to Establish Circular Cross-References
Consider the situation where a "state
" domain domain needs to reference to "country
" and "country" needs and country
needs a reference back to multiple "state
" MDRs MDRs.
This creates a problem since the schema for one will exist before the other. To remedy one of the domains can be updated after both are created. For example:
1. POST the domain for "state" state
with a modelSchema model schema that includes a reference to "country
" with with no `xrefLocation` xrefLocation
:
Code Block | ||
---|---|---|
| ||
"name": { "type": "string" }, "country": { "type": "uri", "uriType": "xref" } |
2. POST the domain for "country
" with with a modelSchema model schema that includes a reference to "state
" including including the `xrefLocation` xrefLocation
:
Code Block | ||
---|---|---|
| ||
"name": { "type": "string" }, "state": { "type": "uri", "uriType":"xref" } |
3. PUT the domain for "state
" with with a modelSchema model schema that includes the reference to "country
":
Code Block | ||
---|---|---|
| ||
"name": { "type": "string" }, "country": { "type": "uri", "uriType": "xref", "xrefLocation": "/domain/country:v1/name" } |
Data can be posted only if all uri's of type `xref` have valid `xrefLocation`s xref
have valid xrefLocation
`s.
NOTE: PUTing a domain is denied if any data is POSTed to the domain:version
.
Using UUIDs
The underlying store in YOUnite uses UUIDs to access data elements. UUIDs can be used instead of domain paths. See Using UUIDs Instead of Domain or MDR Pathnames for more.