To build a social graph

This protocol supports all graph databases conforming to the RDF specification.

We can have a simple social graph by importing the RDF data constructed from the last chapter.

Figure 7-3 A simple social graph

To use Neptune

Amazon Neptune is a fast and scalable graph database service. It can efficiently store and navigate highly interconnected data. Its query processing engine is optimized for leading graph query languages such as Apache TinkerPopâ„¢ Gremlin and W3C's RDF SPARQL. Neptune provides high performance via these open graph frameworks and standard APIs.

With Amazon Neptune we can build a social graph using users' behavioral data on the blockchain.

Steps:

  1. Launch a Neptune instance via the aws console.

  2. Composite the sparql constructed from the last chapter into an "insert" command in Neptune:

  1. Call the Neptune service interface to save RDF:

By now we have indexed the data Alice follow Bob into the graph database. We can query the data via the Neptune service interface:

To use Jena

For demonstration purposes, we will use docker to launch a Jena service:

If successful, please visit http://localhost:3030/ using the account "admin" and password "pw123".

  1. First please create a dataset:

Figure 7-4 Add a dataset
Figure 7-5 Create demo dataset
  1. Then import the data from the last step into the graph database.

Figure 7-6 Upload RDF data
Figure 7-7 Select a file and upload
  1. Finally, switch to the Query tag to query which people Alice has followed:

Figure 7-8 Query with SPARQL
Figure 7-9 Query result

The query result is : Alice's address 0x0109c8ee3151bde7b6b5d9f37e9d2c4bc16930fe followed Bob's address 0x6247123ec0fe0d25feb811e3c4d4a760c1f2e63e.

To use Neo4j

For demonstration purposes, we will use docker to launch a Neo4j service:

  1. Install plugins to support RDF

  1. Configure Plugin

Open file: conf/neo4j.conf and append dbms.unmanaged_extension_classes=n10s.endpoint=/rdf.

then restart Neo4j Service:

Open Neo4j Browser: http://localhost:7474/browser/ Default login is username 'neo4j' and password 'neo4j'.

  1. Configure Graph

Execute the following commands in the Neo4j browser input box:

  1. Importing RDF Data

Execute the following commands in the Neo4j browser input box:

  1. Querying

Execute the following commands in the Neo4j browser input box:

Figure 7-10 To use Neo4j

Last updated