Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First thing to note is that there is no such thing as a key, really, in RDF/SPARQL. You're querying a graph, and <code>?subjectID</code> may simply have several possible combinations of values for the other variables you are selecting. This is caused by the shape of the graph you're querying: perhaps your person has more than one english name, or indeed the other way around: the same english name can be shared by more than one person. </p> <p>A SPARQL SELECT query is a strange beast: it queries a graph structure but presents the result as a flat table (technically, it's a sequence of sets of variable bindings, but it amounts to the same thing). Duplicates occur because different combinations of values for your variables can be found by basically following different paths in the graph.</p> <p>The fact that you get duplicate values for <code>?subjectID</code> in your result is therefore unavoidable, simply because these are, from the point of view of the RDF graph, unique solutions to your query. You can not filter out results without actually losing information, so in general it's hard to give you a solution without knowing more about exactly <em>which</em> 'duplicates' you want to discard: do you only want one possible english name for each subject, or one possible date of birth (even though there may be more than one in your data)? </p> <p>However, here are some tips for handling/procesing such results more easily:</p> <p>First of all, you could choose to use an <code>ORDER BY</code> clause on your <code>?subjectID</code> variable. This will still give you several rows with the same value for <code>?subjectID</code>, but they'll all be in order, so you can process your result more efficiently. </p> <p>Another solution is to split your query in two: do a first query that <em>only</em> selects all unique subjects (and possibly all other values for which you know, in advance, that they will be unique given the subject), then iterate over the result and do a separate query to get the other values you're interested in, <em>for each individual subjectID value</em>. This solution may sound like heresy (especially if you're from an SQL background), but it might actually be quicker and easier than trying to do everything in one huge query.</p> <p>Yet another solution is the one suggested by RobV: using a <code>SAMPLE</code> aggregate on a particular variable to just select one (random) unique value. A variation on that is to use the <code>GROUP_CONCAT</code> aggregate, which creates a single value by concatenating all possible values into a single string. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload