[Fiware-tech-help] Data Modeling with NGSI-LD: Relationship re-utilization

daniel.gonzalez.sanchez daniel.gonzalez.sanchez at alumnos.upm.es
Thu Dec 10 13:31:13 CET 2020


Good morning,

I have a doubt relative to Relationship attribute definition in a 
NGSI-LD data models. I was wondering if is posible to re-use the same 
relationship (with the same relationship name) to point to different 
Entity types encoded as the objects of the relationship itself.

For example, if we have the use case of a Store that sells different 
type of electronics Items (e.g. computers, smartphones or printers), can 
we establish the relationship between a Store entity and these types of 
Item entities (Computer, Smartphone and Printer) with the same "hasItem" 
Relationship? In this use case, would the data model lose semantics?

NGSI-LD simplified representation for Store entity pointing to Computer 
and Printer entity objects:

{
     "id": "urn:ngsi-ld:Store:store-1",
     "type": "Store",
     "hasItem": [{
          "type": "Relationship",
          "object": "urn:ngsi-ld:Computer:computer-HP-0001"
      },{
          "type": "Relationship",
          "object": "urn:ngsi-ld:Printer:printer-HP-0001"

      }]
...
}

I've seen in different tutorials of FIWARE about data models in NGSI-LD 
that one NGSI-LD entity with different relationships of properties 
(relationship like a metadata of property) can re-use the same type of 
relationship. There is an example of this with a "providedBy" 
relationship between Building properties and Temperature and 
FillingLevel Sensors entities in Step-by-Step for NGSI-LD Tutorial of 
FIWARE: 
https://ngsi-ld-tutorials.readthedocs.io/en/latest/datamodels.html

My doubt is about if is posible to re-use the same type of relationship 
between different entities if we use normal relationship like "hasItem" 
in the explained use case (no metadata Relationship of Property like 
"providedBy").

If this were posible, like "hasItem" is a multi-relationship entry with 
different entity objects, it would be necessary to introduce a 
"datasetId" parameter in each relationship instance in "hasItem" to 
uniquely identify these relationship instances (i.e. one datasetId por 
Computer instance object and another one for Printer instance object in 
the hasItem multi-relationship)? I think not because this 
multi-relationship entry points to different types of entities and it 
would not be necessary to uniquely identify them.

Finally, also I was wondering if is posible to re-use the same 
relationship (with the same relationship name) in different types of 
Entities. For example, if we have the use case of two different stores: 
Electronic Store and Garden Store that sells different types of Items, 
can we re-use the same "hasItem" Relationship for both ElectronicStore 
and GardenStore entities?

NGSI-LD simplified representations for ElectronicStore and GardenStore 
entities using the "hasItem" Relationship:

{
     "id": "urn:ngsi-ld:ElectronicStore:electronic-store-1",
     "type": "ElectronicStore",
     "hasItem": {
          "type": "Relationship",
          "object": "urn:ngsi-ld:Computer:computer-HP-0001"
      }
...
}

{
     "id": "urn:ngsi-ld:GardenStore:garden-store-1",
     "type": "GardenStore",
     "hasItem": {
          "type": "Relationship",
          "object": "urn:ngsi-ld:Mower:mower-model-AX23"
      }
...
}


Thank you very much in advance. Sincerely,

Daniel González Sánchez



More information about the Fiware-tech-help mailing list

You can get more information about our cookies and privacy policies clicking on the following links: Privacy policy   Cookies policy