0

The SPARQL graph concept is still abstract for me.

Are graphs similar to SQL Tables? Does one triple could belong to more than one graph?

Is there a way to get the URI of the graph to which belongs a triple?

Is there a way to get the URI of every graph stored in a GraphDB repository? To get the URI of the default graph?

Thanks,

7
  • 2
    get all graphs: select distinct ?g {graph ?g {?s ?p ?o}} Commented Apr 22, 2020 at 10:31
  • 2
    get all graphs that contain a triple: select distinct ?g {graph ?g {:s :p :o}} Commented Apr 22, 2020 at 10:32
  • 2
    and don't compare graphs with SQL tables. An RDF graph is nothing more than a set of RDF triples, that's it Commented Apr 22, 2020 at 10:33
  • 1
    what do you mean by 0 results? If you just load to the default graph, then there are obviously no named graphs. graph ?g always refers to named graphs. A default graph has no URI, why should it? Commented Apr 23, 2020 at 9:39
  • 1
    In SPARQL, SELECT ?g { GRAPH ?g {}} lists the graph URIs. Commented Apr 23, 2020 at 11:42

2 Answers 2

1

In addition of the answers of UninformedUser, graphs also could be listed using the following cURL command curl 'http://<host>:<port>/repositories/<your_repo>/contexts'.

One could easily explore and export the content of graphs in GraphDB repository using Workbench.enter image description here

Here could be found the value of the default graph as well.

Sign up to request clarification or add additional context in comments.

Comments

0

To understand the differences, we could refer first to the data model itself:

Relational model

SQL operates on relational databases. Relational model, in general terms, is a way to model your data and its dependencies as structured tables. If we want to query information that is built out of more than one table, then we perform what is called the join operation that retrieves the relationships between elements in different tables. The join operator often uses keys that are common among the tables. One drawback of this model is when you need to perform many of such join operations to retrieve the desired information. In this case, the response becomes very slow and the performance drops significantly.

Graph model

In contrast, SparQL is a query language that has a SQL-like syntax but operates on graph data. The graph data model does not store the data as tables. Instead, it uses the triple store (another option is to use a Property Graph, but your question refers to triple store). RDF triples are the W3C standard way for describing statements in the graph data model. It consist of Subject, Predicate, Object. Subject is the entity to which the triple refers, Predicate is the type of relationship it has, and Object is the entity or property to which is the subject connects. The subject has always a unique identifier (e.g, URI), whereas the object can be a literal or another entity with an URI.

Further comparison

You can have a look at a more detailed comparison of the models in chapter 2 (Options for Storing Connected Data) of the book: Graph Databases, 2nd Edition by Ian Robinson, Jim Webber, Emil Eifrem

Coming back to your questions

Are graphs similar to SQL Tables? Does one triple could belong to more than one graph?

No, graphs are not SQL tables. And yes, one triple could appear in different graphs (as long as the triple has the same Subject, Predicate, and Object). However, if you use different ontologies, the triple would appear in a different context.

Is there a way to get the URI of the graph to which belongs a triple? Is there a way to get the URI of every graph stored in a GraphDB repository? To get the URI of the default graph?

The SparQL queries are graph patterns. You need to specify the type of structure you are searching for.

As UninformedUser commented:

All triples

select distinct ?g {graph ?g {?s ?p ?o}}

All structures that contain an specific triple

select distinct ?g {graph ?g {:s :p :o}}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.