Query/Examples

From Rhizome Artbase

Simple Queries

Artists in the ArtBase

SELECT DISTINCT ?artistLabel ?artistPage ?artworkLabel ?artworkPage
WHERE {
  ?artwork rt:P3 r:Q5 ;                # Select artworks.
           rdfs:label ?artworkLabel .  # Human-readable label for artwork (title).
  ?artworkPage schema:about ?artwork ; # Select human-readable URL for artwork.
               schema:isPartOf <https://artbase.rhizome.org/> .
  
  ?artwork rt:P29 ?artist.             # Select artists as credited in artwork record.
  ?artistPage  schema:about ?artist ;  # Select human-readable URL for artist.
               schema:isPartOf <https://artbase.rhizome.org/> .
  ?artist rdfs:label ?artistLabel ;    # Human-readable label for artist (name).
          rt:P135 ?sortByName .        # Sort key (for instance, last name > first name.
  
}
ORDER BY ?sortByName

Creation date of artworks grouped by year

#defaultView:BarChart
SELECT (STR(?year) AS ?year_of_inception)
(COUNT(?year) AS ?amount_of_artworks)
{
  {
    SELECT DISTINCT ?artwork (YEAR(?inception) AS ?year) {
      ?artwork rt:P3 r:Q5 ;
               rt:P26 ?inception .
    }
  }
}
GROUP BY ?year
ORDER BY ?year

Creation date of artworks accessioned for the "Some Tumblrs" open call

#defaultView:Timeline

SELECT ?artwork_inception ?artwork_title ?artwork_page ?image {
  
  # Subquery to receive a single random image for each artwork (via SAMPLE)
  # that was accessioned in the "Some Tumblrs" open call
  {   
    SELECT DISTINCT ?artwork ?artwork_inception ?artwork_title (SAMPLE(?artwork_image) AS ?image) {
     ?artwork rt:P3 r:Q5 ;            # Instance of artwork.
            rt:P129 r:Q15261 ;        # Type of Accession has to be "Some Tumblrs Open Call".
            rt:P126 ?artwork_image .  # Images associated with the artwork.
     }
     GROUP BY ?artwork ?artwork_title ?artwork_inception # Group by everything except the image.
  }
  
  # Add more information to the artworks and images selected above:
  
  ?artwork_page schema:about ?artwork ;  # Human-readable URL
                schema:isPartOf <https://artbase.rhizome.org/> .
  
  ?artwork rt:P26 ?artwork_inception ;   # Start date of the tumblr blog (inception)
           rdfs:label ?artwork_title     # Human readable label of the artwork (the work's title)
  
}

Template queries

All artworks by a single artist, listing variants, variant types, and access links

SELECT ?artwork ?artworkLabel ?variant ?variantLabel ?type_of_variant ?type_of_variantLabel ?accessURL WHERE {
  ?artwork rt:P29 r:Q108.   #You can select another artist by changing the Q ID in this line, or by picking an artist from the dropdoqn in the Query Helper.
  ?artwork rt:P45 ?variant.   #This line selects artworks with variants.
  ?variant rt:P3 ?type_of_variant.   #This line specifies the type of variant.
  ?variant rt:P46 ?accessURL.   #This line provides the access link to the variant directly.
  FILTER (?type_of_variant != r:Q1168)   #This line filters out  the parent "variant" category, leaving only specific types like "ouside link", etc.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } #This line facilitates the labeling service, which lists database item with their human-readable labels, and not just their Q IDs.
} 
LIMIT 200

All artworks accessioned into the archive in a given year

#defaultView:ImageGrid
SELECT ?artworkPage ?artworkLabel ?accession_date ?image WHERE {
  { #This sub-query selects a single image per artworks, so that you can view all artworks in an image grid.
    SELECT DISTINCT ?artwork (SAMPLE(?image) AS ?image) WHERE { 
      ?artwork rt:P3 r:Q5;
        rt:P126 ?image.
    }
    GROUP BY ?artwork
  }
  ?artworkPage schema:about ?artwork; #This line selects the main artwork page as an access point, rather it's database record .
  schema:isPartOf <https://artbase.rhizome.org/>.
  ?artwork rt:P85 ?accession_date. #This line selects the data of accession.
  FILTER((?accession_date > "2010-01-01"^^xsd:dateTime) && (?accession_date < "2010-12-31"^^xsd:dateTime)) #This is the line you can edit if you want to pick a different year, or date range to query. Use the standard format of YYYY-MM-DD.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }  #This line facilitates the labeling service, which lists database item with their human-readable labels, and not just their Q IDs.
}
ORDER BY ?accession_date
LIMIT 1000

Data format composition of an artwork variant

SELECT DISTINCT ?variant ?artifact ?data_format_label {
  VALUES ?variant { r:Q12685 }                 # Limit query to a single variant.
  ?variant rt:P139 ?artifact .                 # Check the variant's artifacts.
  ?artifact rt:P81 ?data_format .              # List artifact's data formats.
  ?data_format rdfs:label ?data_format_label . # Human readable label for data format.
}

Queries which use different forms of data visualization

Artworks created per year

#defaultView:BarChart
SELECT (STR(?year) AS ?year_label) (COUNT(?artwork) AS ?artworks) WHERE {
  SELECT (YEAR(?inception) AS ?year) ?artwork WHERE {
    SELECT ?inception ?artwork WHERE {
      ?artwork rt:P3 r:Q5 ;
               rt:P26 ?inception .
    }
  }
}
GROUP BY ?year
ORDER BY ?year


Artworks with more than one artist

#defaultView:Graph
SELECT DISTINCT ?artwork ?artworkLabel ?image ?artist ?artistLabel WHERE {
    ?artwork rt:P3 r:Q5;
    rt:P29 ?artist;
    rt:P126 ?image.
  {
    SELECT DISTINCT ?artwork (COUNT(?artist) AS ?count)  WHERE {
    ?artwork rt:P3 r:Q5;
    rt:P29 ?artist.
      }
    GROUP BY ?artwork
    ORDER BY DESC(?count)
   }
  FILTER (?count>1)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
LIMIT 1000

Collectives in the ArtBase with the names of their members

#defaultView:Graph
SELECT ?collective ?collectiveLabel ?rgb ?member ?memberLabel
WHERE {
  ?collective rt:P3 r:Q7;
              rt:P43 ?member.
  BIND('ffff00' as ?rgb)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}

Artists with more than 10 works in the archive

#defaultView:BubbleChart
SELECT ?artist ?artistPage ?artistLabel ?count  WHERE {
  { SELECT ?artist (COUNT(?artwork) AS ?count)  WHERE {
  ?artwork rt:P3 r:Q5;
  rt:P29 ?artist.
   }
  GROUP BY ?artist
  ORDER BY DESC(?count)
  }
  FILTER (?count>9)
  ?artistPage schema:about ?artist ;
  schema:isPartOf <https://artbase.rhizome.org/> .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}                        
ORDER BY DESC(?count)

Artworks with more than two variants

#defaultView:Tree
SELECT DISTINCT ?artwork ?artworkLabel ?variant ?variantLabel WHERE {
    ?artwork rt:P3 r:Q5;
    rt:P45 ?variant.
   {
    SELECT DISTINCT ?artwork (COUNT(?variant) AS ?count)  WHERE {
    ?artwork rt:P3 r:Q5;
    rt:P45 ?variant.
      }
    GROUP BY ?artwork
    ORDER BY DESC(?count)
   }
  FILTER (?count>2)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
LIMIT 1000

Artworks with web archive variant

#defaultView:ImageGrid
SELECT ?artworkLabel ?URL ?image WHERE {
  { 
  SELECT ?artworkLabel (SAMPLE (?image) as ?image) WHERE {
  ?artwork rt:P3 r:Q5;
           rt:P126 ?image.
  ?artwork rt:P45 ?variant.
  ?variant rt:P3 ?varianttype.
  FILTER (?varianttype = r:Q11994)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  }
  GROUP BY ?artworkLabel
  }
  ?artwork rt:P45 ?variant.
  ?variant rt:P3 ?varianttype.
  FILTER (?varianttype = r:Q11994)
  ?variant rt:P46 ?URL.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
LIMIT 1000

Number of artworks per version of Flash

#defaultView:BarChart
SELECT ?Flash_versionLabel (COUNT(?variant) AS ?count) WHERE {
  ?variant rt:P3 r:Q1168;
           rt:P81 ?Flash_version.
  VALUES ?Flash_version {r:Q4571 r:Q4599 r:Q4598 r:Q4595 r:Q4594 r:Q4597 r:Q4622}
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
GROUP BY ?Flash_versionLabel 
ORDER BY ?count
LIMIT 1000

Federated Queries

Artists in the ArtBase who are also listed in Wikidata

SELECT DISTINCT ?person ?personLabel ?wikidata_item ?image_artbase ?image_wikidata WHERE {
  ?person rt:P3   r:Q6 ;
          rt:P2   ?wikidata_item ;
          rt:P135 ?sort_by_name .
  OPTIONAL { 
    ?person rt:P126 ?image_artbase. 
  }
  SERVICE wdqs: {
    ?wikidata_item rdfs:label ?personLabel.
    OPTIONAL { 
      ?wikidata_item wdt:P18 ?image_wikidata. 
    }
    FILTER((LANG(?personLabel)) = "en")
  }
}
ORDER BY ?sort_by_name

Where Rhizome artists went to school

SELECT DISTINCT ?person ?remote_item ?person_label ?educated_at_label WHERE {  
  ?person rt:P3 r:Q6 ; # instance of (P3) person (Q6)
          rt:P2 ?remote_item ; # exact match with external URL
          rdfs:label ?person_label ;
          rt:P135 ?sort_key .
  FILTER ( STRSTARTS(STR(?remote_item), 'http://www.wikidata.org') )
  
  SERVICE wdqs: {      
    ?remote_item wdt:P69 ?educated_at .
    ?educated_at rdfs:label ?educated_at_label .  
    FILTER (lang(?educated_at_label) = "en")
  }
}
ORDER BY ?sort_key

Citizenship of artists in the ArtBase

#defaultView:BarChart
SELECT DISTINCT ?person ?remote_item ?person_label ?citizenship_label WHERE {  
  ?person rt:P3 r:Q6 ; # instance of (P3) person (Q6)
          rt:P2 ?remote_item ; # exact match with external URL
          rdfs:label ?person_label ;
          rt:P135 ?sort_key .
  FILTER ( STRSTARTS(STR(?remote_item), 'http://www.wikidata.org') )
  
  SERVICE wdqs: {      
    ?remote_item wdt:P27 ?citizenship .
    ?citizenship rdfs:label ?citizenship_label .  
    FILTER (lang(?citizenship_label) = "en")
  }
}
ORDER BY ?sort_key