{"activeVersionTag":"latest","latestAvailableVersionTag":"latest","collection":{"info":{"_postman_id":"8f9fb52f-f756-439f-984c-b9d273376f4b","name":"NGSI-LD Linked Data","description":"This tutorial introduces linked data concepts to the FIWARE Platform. The supermarket chain’s store finder application\nis recreated using **NGSI-LD** the differences between the **NSGI v2** and **NGSI-LD** interfaces are highlighted and\ndiscussed. The tutorial is a direct analogue of the original getting started tutorial but uses API calls from the\n**NGSI-LD** interface.\n\nThe `docker-compose` files for this tutorial can be found on GitHub: \n\n![GitHub](https://fiware.github.io/tutorials.Linked-Data/icon/GitHub-Mark-32px.png) [FIWARE 601: Linked Data](https://github.com/Fiware/tutorials.Linked-Data)\n\n\n# Adding Linked Data concepts to FIWARE Data Entities.\n\n> “Six degrees of separation doesn't mean that everyone is linked to everyone else in just six steps. It means that a\n> very small number of people are linked to everyone else in a few steps, and the rest of us are linked to the world\n> through those special few.”\n>\n> ― Malcolm Gladwell, The Tipping Point\n\nThe introduction to FIWARE [Getting Started tutorial](https://github.com/FIWARE/tutorials.Getting-Started) introduced\nthe [NSGI v2](https://fiware.github.io/specifications/OpenAPI/ngsiv2) interface that is commonly used to create and\nmanipulate context data entities. An evolution of that interface has created a supplementary specification called\n[NGSI-LD](https://forge.etsi.org/swagger/ui/?url=https://forge.etsi.org/gitlab/NGSI-LD/NGSI-LD/raw/master/spec/updated/full_api.json)\nas a mechanism to enhance context data entities though adding the concept of **linked data**. This tutorial will\nintroduce the background of the ideas behind the new interface and compare and contrast how to create and manipulate\ndata entites as linked data.\n\nAddtional tutorials in the series will further discuss data relationships an how to create context data entities using\nlinked data enabling the full knowledge graph to be traversed.\n\n## What is Linked Data?\n\nAll users of the Internet will be familiar with the concept of hypertext links, the way that a link on one web page is\nable to guide the browser to loading another page from a known location.\n\nWhilst humans are able to understand relationship discoverability and how links work, computers find this much more\ndifficult, and require a well-defined protocol to be able to traverse from one data element to another held in a\nseparate location.\n\nCreating a system of readable links for computers requires the use of a well defined data format\n([JSON-LD](http://json-ld.org/)) and assignation of unique IDs\n([URLs or URNs](https://stackoverflow.com/questions/4913343/what-is-the-difference-between-uri-url-and-urn)) for both\ndata entities and the relationships between entities so that semantic meaning can be programmatically retrieved from the\ndata itself.\n\nProperly defined linked data can be used to help answer big data questions, and the data relationships can be traversed\nto answer questions like _\"Which products are currently avaiable on the shelves of Store X and what prices are they sold\nat?\"_\n\n### Video: What is Linked Data?\n\n[![](http://img.youtube.com/vi/4x_xzT5eF5Q/0.jpg)](https://www.youtube.com/watch?v=4x_xzT5eF5Q \"Introduction\")\n\nClick on the image above to watch an introductory video on linked data concepts\n\nJSON-LD is an extension of JSON , it is a standard way of avoiding ambiguity when expressing linked data in JSON so that\nthe data is structured in a format which is parsable by machines. It is a method of ensuring that all data attributes\ncan be easily compared when coming from a multitude of separate data sources, which could have a different idea as to\nwhat each attribute means. For example, when two data entities have a `name` attribute how can the computer be certain\nthat is refers to a _\"Name of a thing\"_ in the same sense (rather than a **Username** or a **Surname** or something).\nURLs and datamodels are used to remove ambiguity by allowing attributes to have a both short form (such as `name`) and a\nfully specified long form (such `http://schema.org/name`) which means it is easy to discover which attribute have a\ncommon meaning within a data structure.\n\nJSON-LD introduces the concept of the `@context` element which provides additional information allowing the computer to\ninterpret the rest of the data with more clarity and depth.\n\nFurthermore the JSON-LD specification enables you to define a unique `@type` associating a well-defined\n[data model](https://fiware-datamodels.readthedocs.io/en/latest/guidelines/index.html) to the data itself.\n\n### Video: What is JSON-LD?\n\n[![](http://img.youtube.com/vi/vioCbTo3C-4/0.jpg)](https://www.youtube.com/watch?v=vioCbTo3C-4 \"JSON-LD\")\n\nClick on the image above to watch a video describing the basic concepts behind JSON-LD.\n\n## What is NGSI-LD?\n\n**NGSI-LD** is an evolution of the **NGSI v2** information model, which has been modified to improve support for linked\ndata (entity relationships), property graphs and semantics (exploiting the capabilities offered by JSON-LD). This work\nhas been conducted under the ETSI ISG CIM initiative and the updated specification hhas been branded as\n[NGSI-LD](https://www.etsi.org/deliver/etsi_gs/CIM/001_099/009/01.01.01_60/gs_CIM009v010101p.pdf). The main constructs\nof NGSI-LD are: _Entity_, _Property_ and _Relationship_. NGSI-LD Entities (instances) can be the subject of Properties\nor Relationships. In terms of the traditional NGSI v2 data model, Properties can be seen as the combination of an\nattribute and its value. Relationships allow to establish associations between instances using linked data.\n\n### NGSI v2 Data Model\n\nAs a reminder, the NGSI v2 data model is quite simple. It can be summarized as shown below:\n\n![](https://fiware.github.io/tutorials.Linked-Data/img/ngsi-v2.png)\n\nThe core element of NGSI v2 is the data _entity_, typically a real object with a changing state (such as a **Store**, a\n**Shelf** and so on). Entities have _attributes_ (such as `name` and `location`) and these in turn hold _metadata_ such\nas `accuracy` - i.e. the accuracy of a `location` reading.\n\nEvery _entity_ must have a `type` which defines the sort of thing the entity describes, but giving an NGSI v2 entity the\n`type=Store` is relatively meaningless as no-one is obliged to shape their own **Store** entities in the same fashion.\nSimilarly adding an attribute called `name` doesn't suddenly make it hold the same data as someone else's `name`\nattribute.\n\nRelationships can be defined using NGSI v2, but only so far as giving the attribute an appropriate attribute name\ndefined by convention ( e.g. starting with `ref`, such as `refManagedBy`) and assigning the attribute\n`type=Relationship` which again is purely a naming convention with no real semantic weight.\n\n### NGSI LD Data Model\n\nThe NGSI LD data model is more complex, with more rigid definitions of use which lead to a navigable knowledge graph.\n\n![](https://fiware.github.io/tutorials.Linked-Data/img/ngsi-ld.png)\n\nOnce again, _entity_ can be considered to be the core element. Every entity must use a unique `id`\n[URN](https://en.wikipedia.org/wiki/Uniform_resource_name), there is also a `type`, used to define the structure of the\ndata held, which is also a URN. This URN should correspond to a well-defined data model which can be found on the web.\nFor example the URN `https://uri.fiware.org/ns/datamodels/Building` is used to define common data model for a\n[Building](https://fiware-datamodels.readthedocs.io/en/latest/Building/Building/doc/spec/index.html).\n\n_Entities_ can have _properties_ and _relationships_. Ideally the name of each _property_ should also be a well defined\nURN which corresponds to a common concept found across the web (e.g. `http://schema.org/address` is a common URN for the\nphysical address of an item). The _property_ will also have a value which will reflect the state of that property (e.g\n`name=\"Checkpoint Markt\"`). Finally a property may itself have further properties (a.k.a. _properties-of-properties_)\nwhich reflect further information about the property itself. Properties and relationships may in turn have a linked\nembedded structure (of _properties-of-properties_ or _properties-of-relationships or relationships-of-properties_ or\n_relationships-of-relationships_ etc.) which lead to the following:\n\nAn NGSI LD Data Entity (e.g. a supermarket):\n\n-   Has an `id` which must be unique. For example `urn:ngsi-ld:Building:store001`,\n-   Has `type` which should be a fully qualified URN of a well defined data model. For example\n    `https://uri.fiware.org/ns/datamodels#Building`\n-   Has _property_ of the entity, for example, an `address` attribute which holds the adress of the store. This can be\n    expanded into `http://schema.org/address`, which is known as a fully qualified name\n    ([FQN](https://en.wikipedia.org/wiki/Fully_qualified_name)).\n-   The `address`, like any _property_ will have a _value_ corresponding to the _property_ `address` (e.g. _Bornholmer\n    Straße 65, 10439 Prenzlauer Berg, Berlin_\n-   Has a _property-of-a-property_ of the entity, for example a `verified` field for the `address`.\n-   Has a _relationship_ of the entity, for example, a `managedBy` field where the relationship `managedBy` corresponds\n    to another data entity : `urn:ngsi-ld:Person:bob-the-manager`\n-   The relationship `managedBy`, may itself have a _property-of-a-relationship_ (e.g. `since`), this holds the date Bob\n    started working the store\n-   The relationship `managedBy`, may itself have a _relationship-of-a-relationship_ (e.g. `subordinateTo`), this holds\n    the URN of the area manager above Bob in the hierarchy.\n\nAs you can see the knowledge graph is well defined and can be expanded indefinitely.\n\nRelationships will be dealt with in more detail in a subsequent tutorial.\n\n# Prerequisites\n\n## Docker\n\nTo keep things simple all components will be run using [Docker](https://www.docker.com). **Docker** is a container\ntechnology which allows to different components isolated into their respective environments.\n\n-   To install Docker on Windows follow the instructions [here](https://docs.docker.com/docker-for-windows/)\n-   To install Docker on Mac follow the instructions [here](https://docs.docker.com/docker-for-mac/)\n-   To install Docker on Linux follow the instructions [here](https://docs.docker.com/install/)\n\n**Docker Compose** is a tool for defining and running multi-container Docker applications. A\n[YAML file](https://raw.githubusercontent.com/Fiware/tutorials.Identity-Management/master/docker-compose.yml) is used\nconfigure the required services for the application. This means all container services can be brought up in a single\ncommand. Docker Compose is installed by default as part of Docker for Windows and Docker for Mac, however Linux users\nwill need to follow the instructions found [here](https://docs.docker.com/compose/install/)\n\n## Cygwin\n\nWe will start up our services using a simple bash script. Windows users should download [cygwin](http://www.cygwin.com/)\nto provide a command-line functionality similar to a Linux distribution on Windows.\n\n","schema":"https://schema.getpostman.com/json/collection/v2.0.0/collection.json","isPublicCollection":true,"owner":"513743","team":157450,"collectionId":"8f9fb52f-f756-439f-984c-b9d273376f4b","publishedId":"SVYjSMgh","public":true,"publicUrl":"https://documenter-api.postman.tech/view/513743/SVYjSMgh","privateUrl":"https://go.postman.co/documentation/513743-8f9fb52f-f756-439f-984c-b9d273376f4b","customColor":{"top-bar":"FFFFFF","right-sidebar":"4C4C4C","highlight":"233C68"},"documentationLayout":"classic-double-column","version":"8.10.1","publishDate":"2020-01-02T11:02:01.000Z","activeVersionTag":"latest","documentationTheme":"light","metaTags":{},"logos":{}},"statusCode":200},"environments":[],"user":{"authenticated":false,"permissions":{"publish":false}},"run":{"button":{"js":"https://run.pstmn.io/button.js","css":"https://run.pstmn.io/button.css"}},"web":"https://www.getpostman.com/","team":{"logo":"https://res.cloudinary.com/postman/image/upload/t_team_logo_pubdoc/v1/team/d7085d490b9144732c65203aa6e3b68b31884d1c33a86b8a00d15da75147ae33","favicon":""},"isEnvFetchError":false,"languages":"[{\"key\":\"csharp\",\"label\":\"C#\",\"variant\":\"HttpClient\"},{\"key\":\"csharp\",\"label\":\"C#\",\"variant\":\"RestSharp\"},{\"key\":\"curl\",\"label\":\"cURL\",\"variant\":\"cURL\"},{\"key\":\"dart\",\"label\":\"Dart\",\"variant\":\"http\"},{\"key\":\"go\",\"label\":\"Go\",\"variant\":\"Native\"},{\"key\":\"http\",\"label\":\"HTTP\",\"variant\":\"HTTP\"},{\"key\":\"java\",\"label\":\"Java\",\"variant\":\"OkHttp\"},{\"key\":\"java\",\"label\":\"Java\",\"variant\":\"Unirest\"},{\"key\":\"javascript\",\"label\":\"JavaScript\",\"variant\":\"Fetch\"},{\"key\":\"javascript\",\"label\":\"JavaScript\",\"variant\":\"jQuery\"},{\"key\":\"javascript\",\"label\":\"JavaScript\",\"variant\":\"XHR\"},{\"key\":\"c\",\"label\":\"C\",\"variant\":\"libcurl\"},{\"key\":\"nodejs\",\"label\":\"NodeJs\",\"variant\":\"Axios\"},{\"key\":\"nodejs\",\"label\":\"NodeJs\",\"variant\":\"Native\"},{\"key\":\"nodejs\",\"label\":\"NodeJs\",\"variant\":\"Request\"},{\"key\":\"nodejs\",\"label\":\"NodeJs\",\"variant\":\"Unirest\"},{\"key\":\"objective-c\",\"label\":\"Objective-C\",\"variant\":\"NSURLSession\"},{\"key\":\"ocaml\",\"label\":\"OCaml\",\"variant\":\"Cohttp\"},{\"key\":\"php\",\"label\":\"PHP\",\"variant\":\"cURL\"},{\"key\":\"php\",\"label\":\"PHP\",\"variant\":\"Guzzle\"},{\"key\":\"php\",\"label\":\"PHP\",\"variant\":\"HTTP_Request2\"},{\"key\":\"php\",\"label\":\"PHP\",\"variant\":\"pecl_http\"},{\"key\":\"powershell\",\"label\":\"PowerShell\",\"variant\":\"RestMethod\"},{\"key\":\"python\",\"label\":\"Python\",\"variant\":\"http.client\"},{\"key\":\"python\",\"label\":\"Python\",\"variant\":\"Requests\"},{\"key\":\"r\",\"label\":\"R\",\"variant\":\"httr\"},{\"key\":\"r\",\"label\":\"R\",\"variant\":\"RCurl\"},{\"key\":\"ruby\",\"label\":\"Ruby\",\"variant\":\"Net::HTTP\"},{\"key\":\"shell\",\"label\":\"Shell\",\"variant\":\"Httpie\"},{\"key\":\"shell\",\"label\":\"Shell\",\"variant\":\"wget\"},{\"key\":\"swift\",\"label\":\"Swift\",\"variant\":\"URLSession\"}]","languageSettings":[{"key":"csharp","label":"C#","variant":"HttpClient"},{"key":"csharp","label":"C#","variant":"RestSharp"},{"key":"curl","label":"cURL","variant":"cURL"},{"key":"dart","label":"Dart","variant":"http"},{"key":"go","label":"Go","variant":"Native"},{"key":"http","label":"HTTP","variant":"HTTP"},{"key":"java","label":"Java","variant":"OkHttp"},{"key":"java","label":"Java","variant":"Unirest"},{"key":"javascript","label":"JavaScript","variant":"Fetch"},{"key":"javascript","label":"JavaScript","variant":"jQuery"},{"key":"javascript","label":"JavaScript","variant":"XHR"},{"key":"c","label":"C","variant":"libcurl"},{"key":"nodejs","label":"NodeJs","variant":"Axios"},{"key":"nodejs","label":"NodeJs","variant":"Native"},{"key":"nodejs","label":"NodeJs","variant":"Request"},{"key":"nodejs","label":"NodeJs","variant":"Unirest"},{"key":"objective-c","label":"Objective-C","variant":"NSURLSession"},{"key":"ocaml","label":"OCaml","variant":"Cohttp"},{"key":"php","label":"PHP","variant":"cURL"},{"key":"php","label":"PHP","variant":"Guzzle"},{"key":"php","label":"PHP","variant":"HTTP_Request2"},{"key":"php","label":"PHP","variant":"pecl_http"},{"key":"powershell","label":"PowerShell","variant":"RestMethod"},{"key":"python","label":"Python","variant":"http.client"},{"key":"python","label":"Python","variant":"Requests"},{"key":"r","label":"R","variant":"httr"},{"key":"r","label":"R","variant":"RCurl"},{"key":"ruby","label":"Ruby","variant":"Net::HTTP"},{"key":"shell","label":"Shell","variant":"Httpie"},{"key":"shell","label":"Shell","variant":"wget"},{"key":"swift","label":"Swift","variant":"URLSession"}],"languageOptions":[{"label":"C# - HttpClient","value":"csharp - HttpClient - C#"},{"label":"C# - RestSharp","value":"csharp - RestSharp - C#"},{"label":"cURL - cURL","value":"curl - cURL - cURL"},{"label":"Dart - http","value":"dart - http - Dart"},{"label":"Go - Native","value":"go - Native - Go"},{"label":"HTTP - HTTP","value":"http - HTTP - HTTP"},{"label":"Java - OkHttp","value":"java - OkHttp - Java"},{"label":"Java - Unirest","value":"java - Unirest - Java"},{"label":"JavaScript - Fetch","value":"javascript - Fetch - JavaScript"},{"label":"JavaScript - jQuery","value":"javascript - jQuery - JavaScript"},{"label":"JavaScript - XHR","value":"javascript - XHR - JavaScript"},{"label":"C - libcurl","value":"c - libcurl - C"},{"label":"NodeJs - Axios","value":"nodejs - Axios - NodeJs"},{"label":"NodeJs - Native","value":"nodejs - Native - NodeJs"},{"label":"NodeJs - Request","value":"nodejs - Request - NodeJs"},{"label":"NodeJs - Unirest","value":"nodejs - Unirest - NodeJs"},{"label":"Objective-C - NSURLSession","value":"objective-c - NSURLSession - Objective-C"},{"label":"OCaml - Cohttp","value":"ocaml - Cohttp - OCaml"},{"label":"PHP - cURL","value":"php - cURL - PHP"},{"label":"PHP - Guzzle","value":"php - Guzzle - PHP"},{"label":"PHP - HTTP_Request2","value":"php - HTTP_Request2 - PHP"},{"label":"PHP - pecl_http","value":"php - pecl_http - PHP"},{"label":"PowerShell - RestMethod","value":"powershell - RestMethod - PowerShell"},{"label":"Python - http.client","value":"python - http.client - Python"},{"label":"Python - Requests","value":"python - Requests - Python"},{"label":"R - httr","value":"r - httr - R"},{"label":"R - RCurl","value":"r - RCurl - R"},{"label":"Ruby - Net::HTTP","value":"ruby - Net::HTTP - Ruby"},{"label":"Shell - Httpie","value":"shell - Httpie - Shell"},{"label":"Shell - wget","value":"shell - wget - Shell"},{"label":"Swift - URLSession","value":"swift - URLSession - Swift"}],"layoutOptions":[{"value":"classic-single-column","label":"Single Column"},{"value":"classic-double-column","label":"Double Column"}],"versionOptions":[],"environmentOptions":[{"value":"0","label":"No Environment"}],"canonicalUrl":"https://documenter.gw.postman.com/view/metadata/SVYjSMgh"}