# Sample Queries
# At one time, these worked, but I haven't checked them against the current live data. Please leave a comment/tweet/email failures and questions.
#== Books and Schools, by number of loans ==
PREFIX ov:
PREFIX dcterms:
SELECT DISTINCT ?bTitle ?sTitle ?count
WHERE {
?book ov:hudSchoolLoan ?schLoan ;
dcterms:title ?bTitle .
?schLoan ov:hudSchool ?school ;
ov:hudLoanCount ?count .
?school dcterms:title ?sTitle .
}
ORDER BY DESC (?count)
== Books and Courses, by number of loans ==
PREFIX ov:
PREFIX dcterms:
SELECT DISTINCT ?bTitle ?cTitle ?count
WHERE {
?book ov:hudCourseLoan ?cLoan ;
dcterms:title ?bTitle .
?cLoan ov:hudCourse ?course ;
ov:hudLoanCount ?count .
?course dcterms:title ?cTitle .
}
ORDER BY DESC (?count)
# == Books and Suggestions, along with loan counts and courses
PREFIX ov:
PREFIX dcterms:
PREFIX foaf:
PREFIX bibo:
SELECT DISTINCT ?bTitle ?bLoans ?sTitle ?sBefore ?sAfter ?sLoans ?cTitle
WHERE {
?book bibo:isbn10 ?isbn ;
ov:hudSuggestion ?sug ;
dcterms:title ?bTitle ;
ov:hudLoanTotal ?bLoans .
?sug ov:hudBefore ?sBefore ;
ov:hudAfter ?sAfter ;
ov:hudSame ?sSame ;
ov:hudSuggestedBook ?sBook .
?sBook dcterms:title ?sTitle ;
ov:hudLoanTotal ?sLoans ;
ov:hudCourseLoan ?cLoan .
?cLoan ov:hudCourse ?course .
?course dcterms:title ?cTitle .
}
# === Same as above, but with option course, school, and year info (might exceed memory quota) ===
PREFIX ov:
PREFIX dcterms:
PREFIX foaf:
PREFIX bibo:
SELECT DISTINCT ?bTitle ?bLoans ?sTitle ?sBefore ?sAfter ?sLoans ?cTitle ?year ?schTitle
WHERE {
?book bibo:isbn10 ?isbn ;
ov:hudSuggestion ?sug ;
dcterms:title ?bTitle ;
ov:hudLoanTotal ?bLoans .
?sug ov:hudBefore ?sBefore ;
ov:hudAfter ?sAfter ;
ov:hudSame ?sSame ;
ov:hudSuggestedBook ?sBook .
?sBook dcterms:title ?sTitle ;
ov:hudLoanTotal ?sLoans .
OPTIONAL {
?sBook ov:hudCourseLoan ?cLoan .
?cLoan ov:hudCourse ?course .
?course dcterms:title ?cTitle .
}
OPTIONAL {
?sBook ov:hudYearLoan ?yLoan .
?yLoan ov:hudYear ?year .
}
OPTIONAL {
?sBook ov:hudSchoolLoan ?schLoan .
?schLoan ov:hudSchool ?school .
?school dcterms:title ?schTitle .
}
}
# === Same as above, with with required, not optional school, course, and year info (might exceed memory quota) ===
PREFIX ov:
PREFIX dcterms:
PREFIX foaf:
PREFIX bibo:
SELECT DISTINCT ?bTitle ?bLoans ?sTitle ?sBefore ?sAfter ?sLoans ?cTitle ?year ?schTitle
WHERE {
?book bibo:isbn10 ?isbn ;
ov:hudSuggestion ?sug ;
dcterms:title ?bTitle ;
ov:hudLoanTotal ?bLoans .
?sug ov:hudBefore ?sBefore ;
ov:hudAfter ?sAfter ;
ov:hudSame ?sSame ;
ov:hudSuggestedBook ?sBook .
?sBook dcterms:title ?sTitle ;
ov:hudLoanTotal ?sLoans ;
ov:hudCourseLoan ?cLoan ;
ov:hudYearLoan ?yLoan ;
ov:hudSchoolLoan ?schLoan .
?cLoan ov:hudCourse ?course .
?course dcterms:title ?cTitle .
?yLoan ov:hudYyear ?year .
?schLoan ov:hudSchool ?school .
?school dcterms:title ?schTitle .
}
# === CONSTRUCT a graph around an ISBN (This is used by the lookupByISBN option for the Exhibit ===
PREFIX ov:
PREFIX dcterms:
PREFIX foaf:
PREFIX bibo:
CONSTRUCT
{
?book ov:hudSuggestion ?sug ;
dcterms:title ?bTitle ;
ov:hudLoanTotal ?bLoans .
?sug ov:hudBefore ?sBefore ;
ov:hudAfter ?sAfter ;
ov:hudSame ?sSame ;
ov:hudSuggestedBook ?sBook .
?sBook dcterms:title ?sTitle ;
ov:hudLoanTotal ?sLoans .
}
WHERE {
?book bibo:isbn10 "1853463515" ;
dcterms:title ?bTitle ;
ov:hudLoanTotal ?bLoans .
OPTIONAL {
?book ov:hudSuggestion ?sug .
?sug ov:hudBefore ?sBefore ;
ov:hudAfter ?sAfter ;
ov:hudSame ?sSame ;
ov:hudSuggestedBook ?sBook .
?sBook dcterms:title ?sTitle ;
ov:hudLoanTotal ?sLoans .
}
}