Project:SPARQL/examples: Difference between revisions

From WikiFur Data
Jump to navigation Jump to search
(+Convention series with data and logo, Convention instances, including postponements)
 
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
These [[wikipedia:SPARQL|SPARQL]] queries [//furry.wikibase.cloud/query/ can be used] in the local [[wikidata:Wikidata:SPARQL query service|Query Service]]. See [[wikidata:Wikidata:SPARQL tutorial|Wikidata's tutorial]] for an overview. The custom prefix declarations are required, and do not autocomplete (<code>wd:</code> does, but actually queries Wikidata).
==Conventions==
==Conventions==
===Convention series with data and logo===
===Convention series with data and logo URL===
<SPARQL>
<SPARQL>
PREFIX wfd: <http://furry.wiki.opencura.com/entity/>
PREFIX wfd: <https://furry.wikibase.cloud/entity/>
PREFIX wfdt: <http://furry.wiki.opencura.com/prop/direct/>
PREFIX wfdt: <https://furry.wikibase.cloud/prop/direct/>


SELECT ?itemLabel ?creationDate (CONCAT("https://en.wikifur.com/w/images/", substr(?logoMD5, 1, 1), "/", substr(?logoMD5, 1, 2), "/", ?logoFileName) AS ?logoURL)
SELECT ?itemLabel ?creationDate (CONCAT("https://en.wikifur.com/w/images/", substr(?logoMD5, 1, 1), "/", substr(?logoMD5, 1, 2), "/", ?logoFileName) AS ?logoURL)
Line 16: Line 18:
     SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
     SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
}
}
ORDER BY ?creationDate
</SPARQL>
</SPARQL>


===Convention instances, including postponements===
===Convention instances, including postponements===
<SPARQL>
<SPARQL>
PREFIX wfd: <http://furry.wiki.opencura.com/entity/>
PREFIX wfd: <https://furry.wikibase.cloud/entity/>
PREFIX wfdt: <http://furry.wiki.opencura.com/prop/direct/>
PREFIX wfdt: <https://furry.wikibase.cloud/prop/direct/>
PREFIX wfp: <http://furry.wiki.opencura.com/prop/>
PREFIX wfdp: <https://furry.wikibase.cloud/prop/>
PREFIX wfps: <http://furry.wiki.opencura.com/prop/statement/>
PREFIX wfdps: <https://furry.wikibase.cloud/prop/statement/>
PREFIX wfpq: <http://furry.wiki.opencura.com/prop/qualifier/>
PREFIX wfdpq: <https://furry.wikibase.cloud/prop/qualifier/>
SELECT ?eventInstanceLabel ?eventStart ?eventEnd ?eventRank ?eventSeriesLabel  
SELECT ?eventInstanceLabel ?eventStart ?eventEnd ?eventRank ?eventSeriesLabel  
WHERE  
WHERE  
Line 34: Line 37:
   #                duplicate for each start time property
   #                duplicate for each start time property
   #                (not wfdt: to get single eventStart)
   #                (not wfdt: to get single eventStart)
                   wfp:P6 ?eventStartProp.
                   wfdp:P6 ?eventStartProp.
   #                populate start time for the row with  this property
   #                populate start time for the row with  this property
   ?eventStartProp  wfps:P6 ?eventStart.
   ?eventStartProp  wfdps:P6 ?eventStart.
   #                normal or deprecated (rescheduled/cancelled)
   #                normal or deprecated (rescheduled/cancelled)
   ?eventStartProp  wikibase:rank ?eventRank.
   ?eventStartProp  wikibase:rank ?eventRank.
   #                grab end time as qualifier if present (else, one-day event)
   #                grab end time as qualifier if present (else, one-day event)
   OPTIONAL {?eventStartProp wfpq:P7 ?eventEnd}
   OPTIONAL {?eventStartProp wfdpq:P7 ?eventEnd}
  OPTIONAL {?eventInstance wfdt:P3 ?eventLocation}
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
}
ORDER BY DESC(?eventInstanceLabel) DESC(?eventStart) DESC(?eventRank)
ORDER BY DESC(?eventInstanceLabel) DESC(?eventStart) DESC(?eventRank)
</SPARQL>
</SPARQL>

Latest revision as of 00:41, 10 May 2024

These SPARQL queries can be used in the local Query Service. See Wikidata's tutorial for an overview. The custom prefix declarations are required, and do not autocomplete (wd: does, but actually queries Wikidata).

Conventions

Convention series with data and logo URL

PREFIX wfd: <https://furry.wikibase.cloud/entity/>
PREFIX wfdt: <https://furry.wikibase.cloud/prop/direct/>

SELECT ?itemLabel ?creationDate (CONCAT("https://en.wikifur.com/w/images/", substr(?logoMD5, 1, 1), "/", substr(?logoMD5, 1, 2), "/", ?logoFileName) AS ?logoURL)
WHERE
{
    ?item wfdt:P2 wfd:Q2 .
    ?item wfdt:P6 ?creationDate .
    OPTIONAL {
      ?item wfdt:P15 ?logoFileName.
      BIND(MD5(?logoFileName) as ?logoMD5).
    }
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
}
ORDER BY ?creationDate


Convention instances, including postponements

PREFIX wfd: <https://furry.wikibase.cloud/entity/>
PREFIX wfdt: <https://furry.wikibase.cloud/prop/direct/>
PREFIX wfdp: <https://furry.wikibase.cloud/prop/>
PREFIX wfdps: <https://furry.wikibase.cloud/prop/statement/>
PREFIX wfdpq: <https://furry.wikibase.cloud/prop/qualifier/>
SELECT ?eventInstanceLabel ?eventStart ?eventEnd ?eventRank ?eventSeriesLabel 
WHERE 
{
  #                subclass of furcons
  ?eventSeries     wfdt:P2 wfd:Q2.
  #                instance of specific furcon
  ?eventInstance   wfdt:P1 ?eventSeries;
  #                duplicate for each start time property
  #                (not wfdt: to get single eventStart)
                   wfdp:P6 ?eventStartProp.
  #                populate start time for the row with  this property
  ?eventStartProp  wfdps:P6 ?eventStart.
  #                normal or deprecated (rescheduled/cancelled)
  ?eventStartProp  wikibase:rank ?eventRank.
  #                grab end time as qualifier if present (else, one-day event)
  OPTIONAL {?eventStartProp wfdpq:P7 ?eventEnd}
  OPTIONAL {?eventInstance wfdt:P3 ?eventLocation}
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY DESC(?eventInstanceLabel) DESC(?eventStart) DESC(?eventRank)