We use proprietary and third party´s cookies to improve your experience and our services, identifying your Internet Browsing preferences on our website; develop analytic activities and display advertising based on your preferences. If you keep browsing, you accept its use. You can get more information on our Cookie Policy
Cookies Policy
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Your eMail poses some interesting questions which I will attempt to answer. Properties and Relationships are defined within the ETSI specification:

https://www.etsi.org/deliver/etsigs/CIM/001099/009/01.03.0160/gscim009v010301p.pdf

and trying to reduce this 200 page document to a series of bite size tutorials is quite a task. The short answer is yes, one-to-many relationships are fully supported by NGSI-LD, although the official syntax is more verbose than I personally would like.

The 1.3.1 spec supports arrays of relationships as shown:

curl -L -X POST 'http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Building:store001/attrs' \ -H 'Content-Type: application/ld+json' \ --data-raw '{ "furniture": [ { "type": "Relationship", "datasetId": "urn:ngsi-ld:Relationship:1", "object": "urn:ngsi-ld:Shelf:001" } ,

{ "type": "Relationship", "datasetId": "urn:ngsi-ld:Relationship:2", "object": "urn:ngsi-ld:Shelf:002" } ], "@context": "https://fiware.github.io/tutorials.Step-by-Step/data-models-context.jsonld" }'

Each element beyond the first must have a unique datasetId. This syntax is also used for Multi valued Properties or GeoProperties (For example where location is being provided by two different sensors e.g. GPS urn:ngsi-ld:GPS or Wifi triangulation. urn:ngsi-ld:WiFi)

The example above comes from the older NGSI-LD for NGSI-v2 Supermarket tutorial https://github.com/FIWARE/tutorials.Relationships-Linked-Data#nine-request I haven't added an equivalent in the newer Smart Farm NGSI-LD first Smart Farm system yet.

The Orion-LD context broker still supports an unofficial simplified syntax:

curl -L -X POST 'http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Building:store001/attrs' \ -H 'Content-Type: application/ld+json' \ --data-raw '{ "furniture":

{ "type": "Relationship", "object": [ "urn:ngsi-ld:Shelf:001", "urn:ngsi-ld:Shelf:002"] } , "@context": "https://fiware.github.io/tutorials.Step-by-Step/data-models-context.jsonld" }'

This mimics the key-values format and also allows one-to-many relationships, but does not allow for meta-data on each element.

As you correctly stated, relationships are directional, and this furniture one-to-many is the direct opposite of reusing something like locatedIn which would appear on multiple entities

curl -X POST \ http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld:Shelf:unit001/attrs \ -H 'Content-Type: application/ld+json' \ -H 'fiware-servicepath: /' \ -d '{ "locatedIn" :

{ "type": "Relationship", "object": "urn:ngsi-ld:Building:store001", } , "@context": "https://fiware.github.io/tutorials.Step-by-Step/data-models-context.jsonld" }'

Within NGSI-LD the object attribute of a Relationship is specified to be a URN - it can point to any other object, so there is no problem with your Combined urn-ngsi-ld:Computer:001 and urn-ngsi-ld:Mower:002 example.