Data modelling
Dr. Antonio Jara
CSO at Libelium
Board of Directors of FIWARE Foundation
[email protected]Information Model
Entity Attributes Metadata
“has” • Name “has” • Name
• EntityId
• Type • Type
• EntityType
1 n • Value 1 n • Value
1
1
Information Model (as UML) – NGSI-LD
2
Information Model - Highlights
NGSI Entity Physical or virtual object.
It has (one) Entity Type.
Uniquely identified by an Entity Id (URI, mandatory in NGSI-LD)
Entity has zero or more attributes identified by a name
Property --> Static or dynamic intrinsic characteristic of an Entity
GeoProperty (geospatial context)
Relationship Association with a Linked entity (unidirectional)
Properties have a value. An NGSI value can be
single value (Number, String, boolean, DateTime).
null is not allowed in NGSI-LD and not recommended.
complex (Array, Structured Value)
Relationships have an object
A URI which points to another entity (target of the relationship). Target can be a collection.
3
Information Model – Highlights (II)
Cross-Domain, core properties for giving context to your information are
defined in a mandatory way, to be used by API operations (e.g. geo queries)
location Geospatial location, encoded as GeoJSON.
observedAt Observation timestamp, encoded as ISO8601. (timestamp in NGSIv2)
createdAt Creation timestamp (of entity, attribute). dateCreated in NGSIv2
modifiedAt Update timestamp (of entity, attribute). dateModified in NGSIv2
unitCode Units of measurement, encoded as mandated by UN/CEFACT.
Recommended practice
Use URIs to identify your entities. (Mandatory in NGSI-LD).
A URN schema is provided off-the-shelf. It enables to know in advance what Entity Type
an Entity id refers to
urn:ngsi-ld:<Entity_Type_Name>:<Entity_Identification_String>
4
Case of Study 1
Smart City
5
Smart City Data Model
Source: ETSI Specification
6
Classical JSON Representation (a.k.a. NGSIv2)
{
"id": "urn:ngsi-ld:OffStreetParking:Downtown1",
"type": "OffStreetParking",
{ "availableSpotNumber": {
"id": "urn:ngsi-ld:Vehicle:A4567", "type": "Property",
"type": "Vehicle", "value": 121,
"brandName": { "metadata" : {
”timestamp": {
"type": "Property", "value" : "2017-07-29T12:00:04Z",
"value": "Mercedes" "type" : "DateTime"
}, },
"isParked": { "reliability": {
"type": "Relationship", "type" : "Property",
"value": "urn:ngsi-ld:OffStreetParking:Downtown1", "value" : 0.7
},
"metadata": { "providedBy": {
”timestamp": { "type" : "Relationship",
"value" : "2017-07-29T12:00:04Z", "value" : "urn:ngsi-ld:Camera:C1"
"type" : "DateTime" }
}, }
"providedBy": { },
"location": {
"type" : "Relationship", "type": "geo:json",
"value" : "urn:ngsi-ld:Person:Bob" "value": {
} "type": "Point",
} "coordinates": [-8.5, 41.2]
} }
} }
}
7
JSON-LD (RDF friendly) representation (a.k.a. NGSI-LD)
{
"id": "urn:ngsi-ld:OffStreetParking:Downtown1",
"type": "OffStreetParking",
{ "availableSpotNumber": {
"id": "urn:ngsi-ld:Vehicle:A4567", "type": "Property",
"type": "Vehicle", "value": 121,
"brandName": { "observedAt": "2017-07-29T12:05:02Z",
"type": "Property", "reliability": {
"value": "Mercedes" "type": "Property",
}, "value": 0.7
"isParked": { },
"type": "Relationship", "providedBy": {
"object": "urn:ngsi-ld:OffStreetParking:Downtown1", "type": "Relationship",
"observedAt": "2017-07-29T12:00:04Z", "object": "urn:ngsi-ld:Camera:C1"
"providedBy": { }
"type": "Relationship", },
"object": "urn:ngsi-ld:Person:Bob" "location": {
} "type": "GeoProperty",
}, "value": {
"@context": [ "type": "Point",
"https://uri.etsi.org/ngsi-ld/v1/", "coordinates": [-8.5, 41.2]
"https://schema.lab.fiware.org/ld/context/" }
] },
} "@context": [
"https://uri.etsi.org/ngsi-ld/v1/",
"https://schema.lab.fiware.org/ld/context/"
]
8 }
Simplified representation (keyValues)
{
"id": "urn:ngsi-ld:OffStreetParking:Downtown1",
"type": "OffStreetParking",
"name": "Downtown One",
"availableSpotNumber": 121,
"totalSpotNumber": 200,
"location": {
"type": "Point",
"coordinates": [-8.5, 41.2]
},
"@context": [
"https://uri.etsi.org/ngsi-ld/v1/",
"https://schema.lab.fiware.org/ld/context/"
]
}
Equivalent in NGSI-LD and NGSIv2
9
Case of Study 2
Smart Agrifood
10
Data Model: Smart Agrifood
11
Classical JSON Representation (a.k.a. NGSIv2)
{ {
"id": "urn:ngsi-ld:Tractor:A4567", "id": "urn:ngsi-ld:AgriParcel:A456",
"type": ”Tractor", "type": ”AgriParcel",
"brandName": { "location": {
"type": "Property", "type" : "geo:json" {
"value" : {
"value": ”John Deere"
"type": "Polygon",
}, "coordinates": [
"speed": { [
type": "Property" 100,
"value": 12, 0
"metadata": { ],
[
”timestamp": {
101,
"value" : "2017-07-29T12:00:04Z", 0
"type" : "DateTime" ],
} [
} 101,
}, 1
],
"isLabouring": {
[
"type": "Relationship", 100,
"value": "urn:ngsi-ld:AgriParcel:A456", 1
"metadata": { ],
"startedAt": { [
"value" : "2017-07-29T12:00:04Z", 100,
0
"type" : "DateTime"
]
} ] }
} }
} } 12
}
JSON-LD (RDF friendly) representation (a.k.a. NGSI-LD)
{
"id": "urn:ngsi-ld:AgriParcel:A456",
{ "type": "AgriParcel",
"id": "urn:ngsi-ld:Tractor:A4567", "location": {
"type" : "GeoProperty" {
"type": ”Tractor", "value" : {
"brandName": { "type": "Polygon",
"type": "Property", "coordinates": [
"value": "Mercedes" [
100,
}, 0
"speed" : { ],
"type": "Property", [
101,
"value": 12,
0
"observedAt": "2017-07-29T12:01:32Z" ],
}, [
"isLabouring": { 101,
1
"type": "Relationship", ],
"object": "urn:ngsi-ld:AgriParcel:A456", [
”startedAt": { 100,
"type": "Property", 1
],
"value": "2017-07-29T12:00:04Z" [
} 100,
}, 0
]
"@context": [
] }
"https://uri.etsi.org/ngsi-ld/v1/", },
"https://schema.lab.fiware.org/ld/context/" "@context": [
] "https://uri.etsi.org/ngsi-ld/v1/",
"https://schema.lab.fiware.org/ld/context/"
} ]
13 }
Simplified representation (keyValues)
{
"id": "urn:ngsi-ld:Tractor:A4567",
"type": ”Tractor",
”brandName": ”John Deere",
”speed": 12,
”isLabouring": ”urn:ngsi-ld:AgriParcel:A456",
"@context": [
"https://uri.etsi.org/ngsi-ld/v1/",
"https://schema.lab.fiware.org/ld/context/"
]
}
Equivalent in NGSI-LD and NGSIv2
14
FIWARE Data Models
1
5
FIWARE Data Models
Landing page: https://schema.fiware.org
Open source project that has developed multiple data models
https://github.com/smart-data-models/data-models
Specifications are crafted using markdown + JSON Schema
Example Weather observed data model
https://github.com/Fiware/dataModels/blob/master/specs/Weather/WeatherObserved/doc/spec.md
https://fiware.github.io/dataModels/specs/Weather/WeatherObserved/schema.json
Data Models Guidelines (how to develop new Data Models)
https://github.com/Fiware/dataModels/blob/master/specs/guidelines.md
Pull Request – Review Lifecycle.
16
References
NGSI-LD FAQ
https://github.com/FIWARE/dataModels/blob/master/specs/ngsi-ld_faq.md
NGSI-LD HowTo
https://github.com/FIWARE/dataModels/blob/master/specs/ngsi-ld_howto.md
ETSI NGSI-LD Specification (January 2019)
https://www.etsi.org/deliver/etsi_gs/CIM/001_099/009/01.01.01_60/gs_CIM009v010101p.pdf
https://docbox.etsi.org/isg/cim/open/Presentation_for_WoT_Plenary_Meeting_Lyon__TPAC_.pdf
FIWARE NGSIv2 Specification
http://fiware.github.io/specifications/ngsiv2/stable/
17
Thank you!
http://fiware.org
Follow @FIWARE on Twitter