Neosemantics support to RDF Named Graphs

Hello,

I’m evaluating Neosemantics according with my project’s requirements. One of the major requirements is support to “RDF Named Graphs (N-Quads)”: An RDF database can store collections of RDF statements (triples) in separate graphs identified (named) by a URI. A group of statements with a unique name is called a ‘named graph’.

Although Neosemantics can import/export N-Quads format, it seems that Neosemantics just stores the RDF Statement (triple) and doesn’t preserve the URI that identifies the name of the Graph.

I’ve tested it in Neo4J Sandbox with following commands:

Importing N-Quad:

call n10s.rdf.import.inline(' <http://example.org/#batman> <http://www.perceive.net/schemas/relationship/enemyOf> <http://example.org/#coringa> <http://example.org/graphs/batman> . ',"N-Quads")

List imported N-Quad:

:GET /rdf/neo4j/describe/http%3A%2F%2Fexample.org%2F%23batman?format=N-Quads

Result:

<http://example.org/#batman> neo4j://graph.schema#enemyOf <http://example.org/#coringa> .

Does anyone knows if Neosemantics really cannot support RDF Named Graphs?

Thanks in advance.

Support is limited and not being maintained so don't expect it to be perfect.

Basically the way it works is it annotates nodes with the graph Uri, which means that you can have multiple nodes in the graph representing the same resource but with different graph uris, or in other words in different named graphs.

I don't think it's a great implementation TBH, give it a try and if it's useful to you do not hesitate to contribute a pull request to improve it :wink:

Here's the code:

// remove the uniqueness constraint on :Resource(uri)
// with named graphs you can have multiple nodes with the same uri but 
// with different graph uris

DROP constraint n10s_unique_uri ;

CREATE INDEX ON :Resource(uri);

//use the experimental procedure to import named graphs
call n10s.experimental.quadrdf.import.fetch(' <http://example.org/#batman> <http://www.perceive.net/schemas/relationship/enemyOf> <http://example.org/#coringa> <http://example.org/graphs/batman> . ',"N-Quads")

1 Like

@jesus_barrasa Thanks for sharing the code.
I was able to store N-Quad data in Neo4J and the named graph information is stored in the graphUri property on every node. However, it is unclear how to write CYPHER queries that would span multiple named graphs. Could you share some insights?
Thanks

Hi Jesus;

@eric.monk I'm thrilled to see the named graph support. Good work!!! Where you aware that the w3c NQuads and SPARQL documentation allows for the fourth member of a quad to be anything. So you can use it for a triple ID and have triples point to and from triples. So you can have fully structured edge metadata - not just properties!!!

You might even consider implementing a SPARQL endpoint. With a partnership arrangement with Franz, you could have structured edge metadata out of the box.

The Visa application is a Requesting of a Visiting.