Tutov1/fr: Difference between revisions

From Resistance in Belgium
No edit summary
No edit summary
Line 40: Line 40:


<!--T:11-->
<!--T:11-->
This approach helps you:
To help you get started, you can:
* <b>Save time</b>;
* Consult our <b>examples of SPARQL queries</b>;
* <b>Avoid common errors</b>;
* Use <b>artificial intelligence tools</b> that can generate queries based on your needs.
* <b>Personalize your searches</b> with precision.


<!--T:12-->
<!--T:12-->
This tutorial will guide you through the basics of SPARQL and show you how to identify the key elements to successfully adapt an existing query.
This tutorial will guide you through the basics of <b>SPARQL</b> and help you identify the <b>key elements</b> to adapt an existing query successfully.
 
<!--T:13-->
<div style="border:2px ;padding:9px; background-color:#158f68;">
<span style="color:#FFFFFF;"><big>3/ The Basics of a SPARQL Query</big></span> </div>
<br>
 
<!--T:14-->
A SPARQL query is made up of a few essential elements. Here are the two main ones:
 
* <span style="color:#158f68;"><b>SELECT</b></span>: this clause lets you <b>choose which information to display</b> in the results. You specify here which elements you want to see.
* <span style="color:#158f68;"><b>WHERE</b></span>: this clause allows you to <b>filter the data</b> by defining precise criteria. This is where you describe the conditions the data must meet.
 
<!--T:15-->
📝 <b>Simple Example</b>
 
<!--T:16-->
Here is a query that extracts the first and last names of people in the database. 
Lines starting with <code>#</code> are <b>comments</b> to explain each part of the query.
 
<syntaxhighlight lang="sparql">
SELECT ?lastName ?firstName
WHERE {
  ?person wdt:P1 wd:Q2 ;      # Selects individuals
          wdt:P3 ?lastName ; # Retrieves the last name
          wdt:P2 ?firstName .# Retrieves the first name
}
</syntaxhighlight>
 
<!--T:17-->
<b>Explanation of the example:</b>
 
<ol>
<li><code>SELECT ?lastName ?firstName</code>:<br>
Indicates that we want to display the values of the <code>?lastName</code> and <code>?firstName</code> variables in the results.</li>
 
<li><code>WHERE { ... }</code>:<br>
Describes the structure and conditions of the query:
<ul>
<li><code>?person wdt:P1 wd:Q2</code>: selects items that are classified as people.</li>
<li><code>wdt:P3 ?lastName</code>: retrieves the last name of the person.</li>
<li><code>wdt:P2 ?firstName</code>: retrieves the first name of the person.</li>
</ul>
</li>
</ol>


</translate>
</translate>

Revision as of 12:21, 1 April 2025

1/ Introduction to SPARQL


Using SPARQL is like being a detective in a vast archive collection. Instead of browsing through each document one by one, you use a language that allows you to instantly find the information matching your criteria with a single precise query.

In the context of Resistance in Belgium, SPARQL makes it easier to access data on resistance members: place of birth, residence, official recognition statuses, or affiliation with a resistance organization.

With SPARQL, you can:

  • Filter and cross-reference information;
  • Customize your searches with specific criteria;
  • Extract precise data without going through thousands of records manually;
  • Generate visualizations to better interpret your results.

This approach gives you valuable autonomy when analyzing data from Resistance in Belgium. You can not only extract lists of names, but also identify complex connections, such as members affiliated with multiple organizations or recognized with different statuses.

SPARQL gives you the superpower every researcher wants: ask an ultra-specific question and see the results appear in milliseconds. Of course, like any superpower, it takes some practice to master. But don’t worry! This tutorial is here to guide you and turn challenges into opportunities… Who said archive research had to be dusty?

Ready to master the force of SPARQL? Let’s go!

2/ Strategy for Your First Queries


Now that you have a general idea of what SPARQL is, here’s a strategy to help you start your research.

There are tools to help write SPARQL queries, but to gain autonomy and flexibility, it’s often more effective to start from an existing query and adapt it to your specific needs.

To help you get started, you can:

  • Consult our examples of SPARQL queries;
  • Use artificial intelligence tools that can generate queries based on your needs.

This tutorial will guide you through the basics of SPARQL and help you identify the key elements to adapt an existing query successfully.

3/ The Basics of a SPARQL Query


A SPARQL query is made up of a few essential elements. Here are the two main ones:

  • SELECT: this clause lets you choose which information to display in the results. You specify here which elements you want to see.
  • WHERE: this clause allows you to filter the data by defining precise criteria. This is where you describe the conditions the data must meet.

📝 Simple Example

Here is a query that extracts the first and last names of people in the database. Lines starting with # are comments to explain each part of the query.

SELECT ?lastName ?firstName
WHERE {
  ?person wdt:P1 wd:Q2 ;      # Selects individuals
          wdt:P3 ?lastName ; # Retrieves the last name
          wdt:P2 ?firstName .# Retrieves the first name
}

Explanation of the example:

  1. SELECT ?lastName ?firstName:
    Indicates that we want to display the values of the ?lastName and ?firstName variables in the results.
  2. WHERE { ... }:
    Describes the structure and conditions of the query:
    • ?person wdt:P1 wd:Q2: selects items that are classified as people.
    • wdt:P3 ?lastName: retrieves the last name of the person.
    • wdt:P2 ?firstName: retrieves the first name of the person.