Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The following SPARQL Update queries are probably mostly correct, but may not be perfect. They focus on LC's LCSH vocabulary, whose resources are sufficiently complex as to make the query patterns more complex than others. 


Steps to replace an authoritative label via SPARQL

Find all the subjects with the matching triple pattern, 
and replace the matched triples with the INSERT triple pattern.

Code Block
DELETE { ?s madsrdf:authoritativeLabel "Dog catcher" } 
INSERT { ?s madsrdf:authoritativeLabel "Dog snatcher" } 
WHERE { 
    ?s madsrdf:authoritativeLabel "Dog catcher"
}

Question:

  • Is there an issue using ?s with it matching many entities?  Should it be a single URI and update the label for that specific entity?


Add a new variant:

Code Block
INSERT { 
    <lcsh:sh123456> madsrdf:hasVariant _:v .
    _:v a madsrdf:Variant .
    _:v madsrdf:variantLabel "Dog catcher" .
}
WHERE { 
    <lcsh:sh123456> madsrdf:authoritativeLabel "Dog snatcher"
}

Question:

  • This one identifies the subject.  

Delete an LCSH resource

1) Delete related component list.  Thanks to:  https://afs.github.io/rdf-lists-sparql

...

Code Block
DELETE {
    <lcsh:sh123456> ?p ?o .
} 
WHERE {
    <lcsh:sh123456> ?p ?o .
}


Deprecate a resource

By rights, there are so many changes that it would probably be better, in reality, to delete the resource and replace it.

...

Code Block
DELETE {
    <lcsh:sh123456> madsrdf:authoritativeLabel ?label .
}
INSERT {
    <lcsh:sh123456> madsrdf:deprecatedLabel ?label .
}
WHERE {
    <lcsh:sh123456> madsrdf:authoritativeLabel ?label .
}


Resource deprecated, but we have a replacement URI

1) Find where the old URI is used, replace it with the new one. Not sure this can be done in one step; might need two steps.  The first to add the new triple, the second to delete the old one.

...