openlink / virtuoso-opensource

Virtuoso is a high-performance and scalable Multi-Model RDBMS, Data Integration Middleware, Linked Data Deployment, and HTTP Application Server Platform
https://vos.openlinksw.com
Other
854 stars 211 forks source link

Why can I not upload this quad onto Virtuoso; even if uploaded, why can I not query with SPARQL? #1313

Open candlecao opened 3 weeks ago

candlecao commented 3 weeks ago

I cannot upload a file with the suffix .nq onto Virtuoso. The content in the file is:

@prefix wdt: <http://www.wikidata.org/prop/direct/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

<https://thesession.org/recordings/1032> <https://thesession.org/tunes> <https://thesession.org/tunes/1> <urn:relationship:1032_1> .
<https://thesession.org/tunes/1> wdt:P658 "12"^^xsd:int <urn:relationship:1032_1> .
<https://thesession.org/tunes/1> wdt:P1114 "1"^^xsd:int <urn:relationship:1032_1> .

<https://thesession.org/recordings/1032> <https://thesession.org/tunes> <https://thesession.org/tunes/629> <urn:relationship:1032_629> .
<https://thesession.org/tunes/629> wdt:P658 "12"^^xsd:int <urn:relationship:1032_629> .
<https://thesession.org/tunes/629> wdt:P1114 "2"^^xsd:int <urn:relationship:1032_629> .

<https://thesession.org/recordings/3536> <https://thesession.org/tunes> <https://thesession.org/tunes/1> <urn:relationship:3536_1> .
<https://thesession.org/tunes/1> wdt:P658 "23"^^xsd:int <urn:relationship:3536_1> .
<https://thesession.org/recordings/3536> <https://thesession.org/tunes/1> wdt:P1114 "1"^^xsd:int <urn:relationship:3536_1> .

However, if I don't use the namespace prefixes, see below, then I can upload the file onto Virtuoso:

<https://thesession.org/recordings/1032> <http://example.org/includes> <https://thesession.org/tunes/1> <urn:relationship:1032_1> .
<https://thesession.org/recordings/1032> <http://www.wikidata.org/prop/direct/P658> "12"^^<http://www.w3.org/2001/XMLSchema#int> <urn:relationship:1032_1> .
<https://thesession.org/tunes/1> <http://www.wikidata.org/prop/direct/P1114> "1"^^<http://www.w3.org/2001/XMLSchema#int> <urn:relationship:1032_1> .

<https://thesession.org/recordings/1032> <http://example.org/includes> <https://thesession.org/tunes/629> <urn:relationship:1032_629> .
<https://thesession.org/recordings/1032> <http://www.wikidata.org/prop/direct/P658> "12"^^<http://www.w3.org/2001/XMLSchema#int> <urn:relationship:1032_629> .
<https://thesession.org/tunes/629> <http://www.wikidata.org/prop/direct/P1114> "2"^^<http://www.w3.org/2001/XMLSchema#int> <urn:relationship:1032_629> .

<https://thesession.org/recordings/3536> <http://example.org/includes> <https://thesession.org/tunes/1> <urn:relationship:3536_1> .
<https://thesession.org/recordings/3536> <http://www.wikidata.org/prop/direct/P658> "23"^^<http://www.w3.org/2001/XMLSchema#int> <urn:relationship:3536_1> .
<https://thesession.org/tunes/1> <http://www.wikidata.org/prop/direct/P1114> "1"^^<http://www.w3.org/2001/XMLSchema#int> <urn:relationship:3536_1> .

Why?

candlecao commented 3 weeks ago

And I cannot query the graph in SPARQL.

HughWilliams commented 3 weeks ago

How are the graphs being uploaded to Virtuoso ?

imitko commented 3 weeks ago

@candlecao

The NQuad file format have no syntax for @prefix see https://www.w3.org/TR/rdf12-n-quads/#sec-grammar-grammar Thus the 1st snippet is NOT Nquad, it is rather Turtle.

HTH

candlecao commented 3 weeks ago

@candlecao

The NQuad file format have no syntax for @prefix see https://www.w3.org/TR/rdf12-n-quads/#sec-grammar-grammar Thus the 1st snippet is NOT Nquad, it is rather Turtle.

HTH

Thank you! But how to query the file in SPARQL? It seems that we cannot use the normal select * where{?s ?p ?o} method. I asked ChatGpt, and it told me to query like:

SELECT * where {
  graph ?g {
    ?s ?p ?o
  }
}

But it doesn't work.

candlecao commented 3 weeks ago

How are the graphs being uploaded to Virtuoso ?

I uploaded it from Conductor > Linked Data > Quad Store Upload. And I found that it doesn't matter whether the quad file is with .nq format or .ttl format.

HughWilliams commented 3 weeks ago

The second NQUAD dataset you provided ie:

<https://thesession.org/recordings/1032> <http://example.org/includes> <https://thesession.org/tunes/1> <urn:relationship:1032_1> .
<https://thesession.org/recordings/1032> <http://www.wikidata.org/prop/direct/P658> "12"^^<http://www.w3.org/2001/XMLSchema#int> <urn:relationship:1032_1> .
<https://thesession.org/tunes/1> <http://www.wikidata.org/prop/direct/P1114> "1"^^<http://www.w3.org/2001/XMLSchema#int> <urn:relationship:1032_1> .

<https://thesession.org/recordings/1032> <http://example.org/includes> <https://thesession.org/tunes/629> <urn:relationship:1032_629> .
<https://thesession.org/recordings/1032> <http://www.wikidata.org/prop/direct/P658> "12"^^<http://www.w3.org/2001/XMLSchema#int> <urn:relationship:1032_629> .
<https://thesession.org/tunes/629> <http://www.wikidata.org/prop/direct/P1114> "2"^^<http://www.w3.org/2001/XMLSchema#int> <urn:relationship:1032_629> .

<https://thesession.org/recordings/3536> <http://example.org/includes> <https://thesession.org/tunes/1> <urn:relationship:3536_1> .
<https://thesession.org/recordings/3536> <http://www.wikidata.org/prop/direct/P658> "23"^^<http://www.w3.org/2001/XMLSchema#int> <urn:relationship:3536_1> .
<https://thesession.org/tunes/1> <http://www.wikidata.org/prop/direct/P1114> "1"^^<http://www.w3.org/2001/XMLSchema#int> <urn:relationship:3536_1> .

loads fine for me and I can see the 3 graphs created with triple counts:

graph                                     count
urn:relationship:1032_1           3
urn:relationship:3536_1           3
urn:relationship:1032_629      3

What is the Virtuoso version being used and what does the output of running the following query to list and count triples in graph report:

SELECT ?graph (count(?s) as ?count) WHERE { GRAPH ?graph { ?s ?p ?o } } GROUP BY ?graph ORDER BY DESC(?count)
candlecao commented 2 weeks ago

Thank you, I will try referring to your advice later.