Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between GraphQL and SPARQL?

I'm doing a lot of research right now on Semantic Web and complex data models that represent relationships between individuals and organizations. I knew a little semantic ontologies although I never understood what it was used if not make graphs.

I saw on university wiki that the language to question an ontology is the SPARQL (tell me if I'm wrong).

But recently I saw a company that had created a semantic ontology put it in the form of GraphQL that I did not know (https://diffuseur.datatourisme.gouv.fr/graphql/voyager/).

It seems to me that semantic ontologies are made to better find information, for example to make a chatbot (it's what I want to do), but here they transformed a semantic ontology into an API, is it right? To make a GraphQL, should I build first a semantic ontology?

Could you explain to me a little the difference between all this, honestly it's a little vague for me.

like image 892
Erwan Pesle Avatar asked Apr 27 '18 13:04

Erwan Pesle


People also ask

What is SPARQL used for?

SPARQL is a declarative programming language and protocol for graph database analytics. SPARQL has the capability to perform all the analytics that SQL can perform, plus it can be used for semantic analysis, the examination of relationships.

What is the difference between SPARQL and SQL?

SQL does this by accessing tables in relational databases, and SPARQL does this by accessing a web of Linked Data. (Of course, SPARQL can be used to access relational data as well, but it was designed to merge disparate sources of data.)

Is SPARQL an API?

A SPARQL Query Service is an HTTP Service (also known as a Web Service) that offers an API for performing declarative Data Definition and Data Manipulation operations on data represented as RDF sentence collections.

Is SPARQL a graph database?

SPARQL is a set of standards for graph databases published by the W3C, but the name is most often used to refer to the query language. As a query language, SPARQL can be used to add, remove and retrieve data from RDF-style graph databases.


1 Answers

Context

Datatourisme is a platform that allows to publish (via the Producteur component) and to consume (via the Diffuseur component) POI-related open data.

It seems you have linked to a particular application developed over Diffuseur with a help of GraphQL Voyager. The application illustrates capabilities of the GraphQL API exposed by Diffuseur.

The API documentation is available here (in French):

  • datatourisme.frama.io/api
  • framagit.org/datatourisme/api

Problem

  • Datatourisme stores data in the RDF format (presumably using the Blazegraph triplestore)
  • Datatourisme provides access via GraphQL (not SPARQL)

Why RDF

  • Partly due to some "schemaless", RDF is convenient in heterogeneous data integration tasks:

    Tourism national ontology structuring in a common sharing format the whole tourism data extracted from different official French data bases: entertainment and events, natural and cultural sites, leisure and sports activities, touristic products, tours, accomodations, shops, restaurants.

  • RDF is semantic: in particular, RDF is self-describing.

SPARQL

  • SPARQL is W3C-standardized language for RDF querying. There were also proposed other RDF query languages.

    BTW, it is possible to query non-RDF sources with SPARQL, e. g. defining R2RML mappings.

  • RDF self-descibeness and SPARQL standardness remove the need to create or to learn a new (shitty) API every day.

GraphQL

  • Similar to SPARQL, GraphQL allows to avoid multiple requests.

  • GraphQL allows to wrap different data sources of different kinds, but typically they are REST APIs.

    As you can see, it is possible to wrap a SPARQL endpoint (there also exists HyperGraphQL).

Why GraphQL

Why Datatourisme have preferred GraphQL?

  • GraphQL is closer to developers and technologies they use en masse. In the past, JSON-LD had the same motivation (however, see my note about JSON-LD here).

  • As it seems, Diffuseur's GraphQL layer provides API keys support and prevents too complex SPARQL queries.

Are data still semantic

  • The answer depends on what you mean by semantic. There was an opinion that even relational model is quite semantical...

  • I'd answer affirmatively, if it's possible to extract e. g. the comment to the :rcs property with GraphQL (and the answer seems to be negative).

Conclusion

Answering your direct question:

  • it is not necessary (though possible) to create a semantic ontology first in order to use GraphQL;
  • it is not necessary (though possible) to use GraphQL after creating a semantic ontology.

Answering your indirect question:

  • probably you need a semantic ontology in order to build such chatbot;
  • probably you need something else in addition.

See also: How is the knowledge represented in Siri – is it an ontology or something else?

Update

In addition to HyperGraphQL, there are other interesting convergence projects:

  • in Stardog
  • in Topbraid
  • in Ontotext Platform
like image 124
Stanislav Kralin Avatar answered Sep 23 '22 14:09

Stanislav Kralin