Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
FIWARE Global Summit - NGSI-LD: Modelling, Linking and Utilizing Context Information
1. Scale Up for a Real Smart Future
Berlin, Germany
23-24 October, 2019
NGSI-LD: Modelling, Linking and Utilizing Context Information
Martin Bauer – NEC Laboratories Europe
2. Outline
§ NGSI-LD: Evolution of NGSI – Why did we decide to evolve NGSI?
§ NGSI-LD Design Goals – What goals do we want to reach?
§ NGSI-LD Information Model
§ NGSI-LD for NGSIv2 programmers – “change as little as possible”
§ NGSI-LD for property graph enthusiasts
§ NGSI-LD and the world of linked data and semantics
§ Conclusions
3. NGSI-LD: Evolution of NGSI – Why did we decide to evolve NGSI?
Make NGSI fit for the future
§ Benefits of independent open standard (i.e. ETSI Group Specification)
• Standards can be referenced in tenders
• Avoid “vendor lock-in”
• Good technical specification to achieve good interoperability
§ Scalability and support of different deployment scenarios
§ Support popular property graph paradigm
§ Basis for AI and connection to world of linked data and semantics
4. NGSI-LD Design Goals – What goals do we want to reach?
§ Change as little as possible with respect to NGSIv2
• Upgrading NGSIv2 applications to NGSI-LD should be simple
• Developers who just want to use plain JSON should be able to do so
§ Support the Property Graph paradigm
• Graphs are a powerful way to represent and process context information
• Connects to the world of knowledge graphs, graph theory and graph
databases
§ Connect to the world of Linked Data and Semantics
• Use clearly defined semantic concepts
• With JSON-LD representation connect to Linked Data
and utilize semantic tools
5. All clipart is under Creative Commons BY 4.0 Licence from https://www.svgrepo.com
NGSI-LD Information Model (1)
Modelling: relationships – from convention to „first-class citizen“
5
Store Store
name: Checker...
address: ...
location: ...
name: Checker
Market
address: ...
location: ...
id: urn:ngsi-ld:Store:001 id: urn:ngsi-ld:Store:001
Customer
id: urn:ngsi-ld:Customer
:285
Customer
id: urn:ngsi-ld:Customer
:285
refVisited: id:
urn:ngsi-
ld:Store:001
name: Paul
name: Paul ...
visited: id: urn:ngsi-ld:Store:001
Attribute
Property
Relationship
• Application‘s may know that the value of
an attribute is the id of another entity, but it
cannot be directly inferred
• Using “ref” as a prefix is a convention that
may help in certain cases, but does not
guarantee the value to refer to an entity
object
• NGSI-LD explicitly introduces the concept of Relationship
• Clear distinction between Properties which have values and
Relationships that have an object pointing to an entity
• No ambiguity and, using JSON-LD, the link is explicit and can be
correctly interpreted by any component, not requiring specific
application knowledge.
Aplication knowledge &
convention
Relationship concept
6. NGSI-LD Information Model (2)
Modeling: relationships create graphs of entities
6
<buildingA>
<room5>
<occupancy>1
10</...>
asNDAGAINqwq
Ajksajasdfahdsjfk
ASD2348FNA;W
Asdafnasd;fmasd
ASwt5iqwerjsfg43
a foaf:Person ;
foaf:name
"Jimmy Wales" ;
foaf:mbox
<mailto:jwales@
bomis.com> ;
foaf:homepage
<http://www.jim
mywales.com>
<situation id="GU
ID2A22530C-D4
52-4ae8-B942-9
93BC2923D13" v
ersion="1">
<overallSeverity>
high<
/overallSeverity>
"contextRegistration": [
{ "entities": [ { "id": "E1",
"type": "T1",
“ isPattern": "false" },
{ "id": "E2",
"type": "T2", “
isPattern": "false" } ],
link to
video
link to
3D model
speed
location,
speed
location
location
address
owns
livesAt
isAttached
Entity (type, identifier)
Property
Relationship
Advantages of
NGSI-LD Entity Graph
• = knowledge graph
• ~ index structure,
follow relationships
to find relevant entities
• retrieve relevant
subset of entities and
use advanced graph
tools
All clipart is under Creative Commons BY 4.0 Licence from https://www.svgrepo.com
7. NGSI-LD Information Model (3)
Modeling: @context – uniquely defining entity types
7
Customer Product Store InventoryItem
Customer
Product
Store
InventoryItem
Shelf
https://forge.etsi.org/gitlab/primerContext/StoreOntology/Customer
https://forge.etsi.org/gitlab/primerContext/StoreOntology/Product
https://forge.etsi.org/gitlab/primerContext/StoreOntology/Store
https://forge.etsi.org/gitlab/primerContext/StoreOntology/InventoryItem
https://forge.etsi.org/gitlab/primerContext/StoreOntology/Shelf
relatesTo https://forge.etsi.org/gitlab/primerContext/StoreOntology/relatesTo
name https://forge.etsi.org/gitlab/primerContext/StoreOntology/name
Entity Types, relationships and
properties play an important role in NGSI
hasVisited hasPurchased relatesTo holds
name location address price
Simple Strings
ü human readable
ü short
à convenient
û often not unique
û problem when
sharing
URIs
ü unique
û long
à cumbersome
Compromise?
Best of both?
@context in JSON-LD
• Define unique URIs
• Define mapping of shortnames
to URIs in @context
• Reference @context and use
shortnames for serialization
8. NGSI-LD for NGSIv2 programmers – “change as little as possible”
Main Changes from NGSIv2 to NGSI-LD
§ @Context is main new element in NGSI-LD as it is based on JSON-LD
§ If available reuse existing @context, e.g. available for FIWARE Data Models
§ Recommended approach for own @context:
• Create @context with ALL terms used
• Make them available on a webserver
• Reference the @context using Link header
§ If context is irrelevant: use default context
§ Type in JSON-LD is the type of the node,
i.e. is the Entity Type, Property, Relationshop
à Data type is implicit, can be defined in @context
or use property of property/relationship
§ Structural simplication: metadata is no longer a
separate substructure, but moves on same
level as value
NGSIv2 Entity NGSI-LD Entity
@context
entity type: string entity type: URI
Id: string Id: URI
Name Data type
Metadata
Name
Property
Name Data type
Metadata
Name
Relationship
9. NGSI-LD for NGSIv2 programmers – “change as little as possible”
Migration Steps
§ Migration Steps from NGSIv2 to NGSI-LD:
• Create suitable JSON-LD @context, ideally containing all relevant terms and make it
available in a location you can link to
• NGSI v2 entity id attributes have to be converted to URIs, preferably using the NGSI-LD URN
• Regular entity attributes have to be converted to JSON-LD nodes of type Property.
• ref attributes (pointing to other entities) have to be converted to JSON-LD nodes of type
Relationship.
• The timestamp metadata item has to be mapped to the observedAt member of a Property node.
• The unitCode metadata item has to be mapped to the unitCode member of a Property node.
• The NGSI v2 DateTime type has to be properly encoded as per the JSON-LD rules.
• The NGSI v2 geo:json type has to be renamed to GeoProperty.
https://fiware-datamodels.readthedocs.io/en/latest/ngsi-ld_howto/index.html
A python script is available that does the syntactical conversion and can be adpapted
for specific cases:
https://github.com/Fiware/dataModels/blob/master/tools/normalized2LD.py
10. NGSI-LD for property graph enthusiasts
§ The NGSI-LD information model represents a special property graph
model
• Nodes of the property graph are entities
• Nodes have properties
• Nodes have relationships to other nodes, i.e. entities in the NGSI-LD case
• Relationships themselves can have properties
• In the case of NGSI-LD, also properties can have properties
§ Property graphs can be stored in (typically centralized) graph databases that
provide expressive query languages
àNGSI-LD data can be stored in graph databases, either as implementation
basis for Brokers implementing the NGSI-LD API or as independent
component exposing the graph query language interface
àSee Thing‘in NGSI-LD compatible Graph Database presented earlier in IoT
Evolution / Digital Twin session
11. NGSI-LD and the world of linked data and semantics
Modeling: linked data and the world of semantics
11
• JSON-LD is JSON for Linked Data – and it is a serialization of RDF
• Information retrieved via NGSI-LD can be used with semantic tools and
combined with existing linked data
The Linked Open Data Cloud from https://lod-cloud.net/
under Creative Commons License
Linked Data
All clipart is under Creative Commons BY 4.0 Licence from https://www.svgrepo.com
12. NGSI-LD and the world of linked data and semantics
Modelling Entity Types, Properties and Relationships in Ontologies
§ @context provides a mapping between strings and URIs,
guarantees uniqueness
§ URIs can refer to concepts and properties in an ontology
§ Thus ontologies can be used to express additional information, e.g.
• Restrictions on the properties and relationships that entities
of a given entity type can have
• Restrictions on the values that a property can have
• Subtype relations between entity types
• Subproperty relations between properties
§ The ontology information can then be used for reasoning
13. NGSI-LD and the World of Linked Data and Semantics
NGSI-LD as Semantic Data
§ NGSI-LD is represented in JSON-LD, which is a serialization of RDF
àNGSI-LD can be used with semantic tools
• NGSI-LD can be put into a triple store
• NGSI-LD (in a triple store) can be queried with SPARQL
<?xml version="1.0" encoding="utf-8"?>
<rdf:RDF
xmlns:ns1="https://w3id.org/ngsi-ld/store/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:ngsi-ld="https://uri.etsi.org/ngsi-ld/"
>
<ns1:Store rdf:about="urn:ngsi-ld:Store:001">
<ns1:storeName>
<ngsi-ld:Property rdf:nodeID="Nc620ba170b42409a8e7545c9d676ad46">
<ngsi-ld:hasValue>Checker Market</ngsi-ld:hasValue>
</ngsi-ld:Property>
</ns1:storeName>
</ns1:Store>
</rdf:RDF>
{
"@context": [
{
"Store": "https://w3id.org/ngsi-ld/store/Store",
"storeName": "https://w3id.org/ngsi-ld/store/storeName",
"streetAddress": "https://w3id.org/ngsi-ld/storestalCode"
},
"https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld"
],
"id": "urn:ngsi-ld:Store:001",
"type": "Store",
"storeName": {
"type": "Property",
"value": "Checker Market"
}
}
NGSI-LD in JSON-LD NGSI-LD in RDF/XML
14. NGSI-LD and the World of Linked Data and Semantics
NGSI-LD and Linked Data
§ NGSI-LD is aligned with Linked Data:
§ All identifiers are URIs
§ URIs are used internally (relationships) and can point to external
information (properties)
§ JSON-LD is used as representation
§ NGSI-LD does not enforce dereferenceable URIs, i.e. that you could
direclty dereference the URI of an entity and get its information
§ Caveat: NGSI-LD uses blank-node reification
15. NGSI-LD and the World of Linked Data and Semantics
Reification
§ In RDF it is not possible to directly attach information to triples
§ Attaching information is necessary to provide meta information and – thus for
representing property graphs
§ The underlying problem is also related to logics and decideability, i.e. meta
information is a statement about a statement and if this is allowed, the resulting
language is not in first-order logic anymore
§ The general way around is to use „re-ification“ – making something, in this case
an property, a „Thing“ – so in this case the property needs to be represented as
a node
CameraA StreetA
monitors
<entity> <value><propertyname> RDF Triple
Example
16. NGSI-LD and the World of Linked Data and Semantics
Reification in NGSI-LD
§ There are multiple approaches for re-ification, the most common ones are
Standard RDF reification, singleton reification and blank node reification
§ For NGSI-LD we have chosen blank node reification
• It fits with the existing JSON structure
• The „blank node“ is not explicitly visible in the JSON-LD representation
CameraA StreetA
monitors
70%
_:blankNode_n
hasObject
hasCoverage
CameraA StreetA
monitors
reification
"id": "urn:ngsi-ld:CameraA,
"type": “Camera",
“monitors":
{
"type": “Relationship",
“object": " urn:ngsi-ld:StreetA "
}
Blank Node
<ns1:Camera>rdf:about="urn:ngsi-ld:Store:001">
<ns1:monitors>
<ngsi-ld:Relationship
rdf:nodeID="Nc730ba170b43419a8e7545c9d676ad48">
<ngsi-ld:hasObject> urn:ngsi-ld:StreetA
</ngsi-ld:hasObject>
</ngsi-ld:Relationship>
</ns1:monitors>
</ns1:Camera>
Blank Node
17. NGSI-LD and the World of Linked Data and Semantics
Using NGSI-LD with Semantic Tools
§ NGSI-LD can be used with Semantic Tools possibly in combination with
ontologies and other semantic data
§ Semantic Tools:
• Triple Stores
• SPARQL Queries
• Reasoners
• RDF Management Libraries
• Ontology Tools
§ BUT: Take into account blank nodes
§ OR: use simplified representation
(where applicable)
SELECT ?camera ?street
WHERE { ?camera monitors ?street }
Non-reified SPARQL Query
(e.g. on simplified representation)
Reified SPARQL Query
(e.g. on regular NGSI-LD
SELECT ?camera ?street
WHERE { ?camera monitors ?node .
?node hasObject ?street }
18. Whitepapers on Semantic IoT Solutions and Semantic
Interoperability
Towards Semantic
Interoperability
Standards based on
Ontologies
Target Group: Semantic Experts, Standardization Engineers &
SDOs
“How to create standards for semantic interoperability”
Semantic IoT Solutions:
A Developer Perspective
Target Group: Developers and
Software Architects
“How to develop semantic systems and achieve semantic
interoperability”
http://dx.doi.org/10.13140/RG.2.2.16339.53286 http://dx.doi.org/10.13140/RG.2.2.26825.29282
Written by a group of experts affiliated with different standardization organizations – published October 22nd, 2019
19. NGSI-LD and the World of Linked Data and Semantics
Distribution & Scalability: Fetch Data Then Process
§ NGSI-LD API is intentially limited in expressiveness so it also works in
distributed and federated settings
§ Scalability of local nodes with expressive query language, in particular
triple stores with SPARQL is limited
§ Proposal for large scale scenarios:
1. Fetch relevant information with
a number of NGSI-LD Queries
2. Use the aggregated results and
locally process with expressive
query language, e.g. SPARQL
with reasoning capabilities on
an (in-memory) triple stores OR
graph database
Application
Broker
1
queries results
push
advanced query
2
20. Conclusions
§ Change as little as possible with respect to NGSIv2
• Limited structural changes, conversion can be done with simple script
• Primarily @context, mapping strings to URIs is needed – use of default
context possible
§ Support the Property Graph paradigm
• The NGSI-LD information model is a specialized property graph
• NGSI-LD can be used with graph databases designed for property graphs
§ Connect to the world of Linked Data and Semantics
• NGSI-LD is based on JSON-LD which is a serialization format of RDF
• URIs used in @context can be defined in ontology, where ontology defines
further restrictions and relations that can be used for reasoning
• NGSI-LD is aligned with linked data
• NGSI-LD can be used with semantic tools
à Yes, it is a compromise – but it is a good one!