Simple Linked Data Deployment Tutorial — using JSON-LD Notation
Here is a simple tutorial that demonstrates the fact that Linked Data deployment is easier than is generally assumed.
In this variant of the tutorial I am using JSON-LD Notation rather than RDF-Turtle Notation.
Why?
I want observations that I document to be “webby”, or “web-like”, in nature; i.e., I want entity relationships that can be navigated by clicking on hyperlinks (HTTP URIs) using a follow-your-nose pattern.
What?
Describe how several entities are related, leveraging the data connectivity and access prowess of Linked Data and the descriptive power of RDF sentences:
- a lady named “Alice”
- a man named “Bob”
- a car manufacturer named “Example Cars & Co”
- an unbranded red automobile (car)
How?
To achieve my goal, I have to adhere to a few fundamental principles:
- Identify (name) entities using HTTP URIs so that anyone can look up their description documents — i.e., leverage the fact that HTTP URIs resolve to documents.
- Use RDF Language subject→predicate→object structured sentences/statements (using a variety of notations) to store entity descriptions in a document that’s also identified by an HTTP URI (more specifically in this case, a URL, since we are dealing with a document on an HTTP network).
- Repeat the process whenever I encounter something of interest — i.e., take notes about what I observe using simple RDF Language sentences.
Steps:
- Create a folder on my local drive.
- Create a document for each entity that I plan to describe —
doc1.ttl
for “Bob” [1],doc2.ttl
for “Alice”[2],org.ttl
for “Example Cars & Co” [3],product.ttl
for the automobile [4]. - Add content in the form of RDF statements (triples) that represent how these entities are related to each document.
- Copy all of my files to an HTTP accessible folder that’s published to a public (e.g., World Wide Web) or private (e.g., Intranet) network.
- Done!
JSON-LD Statements (using Nanotation)
Example 1 — about Bob (friend of Alice who seeks a Car)
## Linked Data using Relative URIs Exercise 1
## JSON-LD Start ##
{
"@context": {
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"foaf": "http://xmlns.com/foaf/0.1/",
"dcterms": "http://purl.org/dc/terms/",
"gr": "http://purl.org/goodrelations/v1#",
"wdrs": "http://www.w3.org/2007/05/powder-s#"
},
"@graph": [
{
"@id": "#",
"@type": "foaf:Document",
"dcterms:description": "A collection of RDF sentences that describe a Person literally identified (or labeled) as 'Bob'",
"foaf:name": "A Document that describes a Person literally identified as 'Bob'",
"foaf:primaryTopic": {
"@id": "#bob"
}
},
{
"@id": "#bob",
"@type": "foaf:Person",
"gr:seeks": {
"@id": "#CoolRedCar"
},
"wdrs:describedby": {
"@id": "#"
},
"foaf:depiction": {
"@id": "http://www.silhouettegraphics.net/wp-content/uploads/2013/10/young-man-silhouettegraphics-.jpg"
},
"foaf:knows": {
"@id": "#alice"
},
"foaf:name": "Bob"
}
]
}
## JSON-LD End ##
Example 2 — about Alice (friend of Bob who is employed by a Car Manufacturer)
## JSON-LD Start ##
{
"@context": {
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"foaf": "http://xmlns.com/foaf/0.1/",
"dcterms": "http://purl.org/dc/terms/",
"rel": "http://purl.org/vocab/relationship/",
"wdrs": "http://www.w3.org/2007/05/powder-s#"
},
"@graph": [
{
"@id": "#",
"@type": "foaf:Document",
"dcterms:description": "A collection of RDF sentences that describe a Person literally identified (or labeled) as 'Alice'",
"foaf:name": "A Document that describes a Person literally identified as 'Alice'",
"foaf:primaryTopic": {
"@id": "#alice"
}
},
{
"@id": "#alice",
"@type": "foaf:Person",
"rel:employedBy": {
"@id": "https://medium.com/openlink-software-blog/org.ttl#exampleCars"
},
"wdrs:describedby": {
"@id": "#"
},
"foaf:depiction": {
"@id": "http://clipart-library.com/images/kiMb8ggKT.jpg"
},
"foaf:knows": {
"@id": "#bob"
},
"foaf:name": "Alice"
}
]
}
## JSON-LD End ##
Example 3 — about Car Maker (who manufactures Cars and employs Alice)
## JSON-LD Start ##
{
"@context": {
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"foaf": "http://xmlns.com/foaf/0.1/",
"dcterms": "http://purl.org/dc/terms/",
"gr": "http://purl.org/goodrelations/v1#",
"wdrs": "http://www.w3.org/2007/05/powder-s#"
},
"@graph": [
{
"@id": "#",
"@type": "foaf:Document",
"dcterms:description": "A collection of RDF sentences that describe an Organization literally identified (or labeled) as 'Example Cars & Co.'",
"foaf:name": "A Document that describes an Organization literally identified as 'Example Cars & Co.'",
"foaf:primaryTopic": {
"@id": "#exampleCars"
}
},
{
"@id": "#exampleCars",
"@type": [
"gr:BusinessEntity",
"foaf:Organization"
],
"wdrs:describedby": {
"@id": ""
},
"foaf:depiction": {
"@id": "https://thumb1.shutterstock.com/display_pic_with_logo/3648824/532862638/stock-vector-silhouette-automated-production-line-robotic-factory-banner-532862638.jpg"
},
"foaf:made": {
"@id": "https://medium.com/openlink-software-blog/product.ttl#CoolRedCar"
},
"foaf:name": "Example Cars & Co."
}
]
}
## JSON-LD End ##
Example 4 — about Car (Product made by Car Maker that employs Alice)
## JSON-LD Start ##
{
"@context": {
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"foaf": "http://xmlns.com/foaf/0.1/",
"dcterms": "http://purl.org/dc/terms/",
"gr": "http://purl.org/goodrelations/v1#",
"wdrs": "http://www.w3.org/2007/05/powder-s#"
},
"@graph": [
{
"@id": "#",
"@type": "foaf:Document",
"dcterms:description": "A collection of RDF sentences that describe a Product literally identified (or labeled) as 'Gift Wrapped Cool Red Car -- Brand Unknown'",
"foaf:name": "A Document that describes a Product literally identified as 'Gift Wrapped Cool Red Car -- Brand Unknown'",
"foaf:primaryTopic": {
"@id": "#CoolRedCar"
}
},
{
"@id": "#CoolRedCar",
"@type": "gr:ProductOrService",
"wdrs:describedby": {
"@id": "#"
},
"foaf:depiction": {
"@id": "http://highroaddigital.com/wp-content/uploads/2015/01/wonanewcar.jpg"
},
"foaf:maker": {
"@id": "#exampleCars"
},
"foaf:name": "Gift Wrapped Cool Red Car -- Brand Unknown"
}
]
}
## JSON-LD End ##
Example 5 — an additional document functioning as an index of all the entity description documents
## JSON-LD Start ##
{
"@context": {
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"foaf": "http://xmlns.com/foaf/0.1/",
"dcterms": "http://purl.org/dc/terms/"
},
"@id": "#",
"@type": "foaf:Document",
"dcterms:description": "A collection of RDF sentences that describe a Linked Data Deployment exercise",
"foaf:depiction": {
"@id": "http://kingsley.idehen.net/DAV/home/kidehen/Public/Linked%20Data%20Documents/Tutorials/slide38_linked_data_network_v2_SPO%20_latest_relative_uris.png"
},
"foaf:name": "A Document about illustrating a simple Linked Data Deployment exercise",
"foaf:topic": [
{
"@id": "#"
},
{
"@id": "/doc1.ttl"
},
{
"@id": "/doc2.ttl"
},
{
"@id": "/product.ttl"
},
{
"@id": "/org.ttl"
}
]
}
## JSON-LD End ##
Additional Notes
JSON-LD and/or Nanotation
I used JSON-LD — based on its Web Programmer friendliness — as the notation for inscribing RDF statements to my documents.
By using nanotation, I am able to use this document (this Medium post) as a 5-Star Linked Data Source and Knowledge Graph in its own right, as you will observe if you install our Structured Data Sniffer extension .
Using Relative URIs is the key to simple Linked Data Deployment. The HTTP Fragment Identifier is a powerful feature that enables HTTP URIs (Hyperlinks) to identify anything. More importantly, it enables their use when identifying the subject, predicate, and object of an RDF sentence; i.e., this is what makes the notion of a Knowledge Graph that manifests as a Semantic Web viable.
Due to what’s outlined above, I am able to deploy this Linked Data Deployment tutorial using the age-old File Create, Save, Copy, and Share pattern across the proprietary storage services provided by Dropbox, Google Drive, Microsoft OneDrive, Amazon S3, etc, starting from my local file system.
Conclusion
By following the steps outlined above, you would have successfully described how four entities (two people, a company, and a product) are related. Even better, you would have achieved the goal of making your effort native to the Web; i.e., your document viewers (human or bots) can simply follow links presented in your documents to better understand the information encoded in the entity relationships you’ve represented in RDF sentences.
At this juncture, I strongly encourage you to watch this video excerpt from a recent documentary about Tim Berners-Lee that sheds light on the inspiration and insights that lead to the creation of the platform known as the World Wide Web.
Related
Here are some tools that enable viewing and exploration of Linked Data using existing browsers:
- Simple Linked Data Deployment Guide using RDF-Turtle Notation
- Using the Briefcase module of our ODS (OpenLink Data Spaces) platform to mount 3rd Party Storage Services (Google Drive, Dropbox, Microsoft OneDrive, Amazon S3, and others)
- About Nanotation — a mechanism for embedding RDF sentences (using RDF-Turtle or JSON-LD notations) wherever plain text is accepted.
- OpenLink Data Explorer — browser extensions for all the major browsers, which are useful in situations where the document publisher doesn’t generate HTML based representations of your description content
- URIBurner Service — a free service for hooking your existing content into the Linked Open Data cloud
- Understanding Data — a presentation that explains what Data actually is and how it’s ultimately about digital terms, statements, and collections of statements (like paragraphs in natural language)
- Linked Data in a Single Slide — a slide from a presentation by Tim Berners-Lee that showcases HTTP Denotation and Connotation duality via the use of fragment Identifier (
#
) part of an HTTP URI - Excerpts from documentary about Tim Berners-Lee and the invention of the Web — a shim that brought the Internet to the masses