-
Notifications
You must be signed in to change notification settings - Fork 1
Query Modes
Daniel Heward-Mills edited this page Sep 27, 2025
·
1 revision
SPARQLWorksβ’ provides two distinct modes for composing SPARQL queries, each designed to serve different user needs and skill levels.
Target Users: Beginners, domain experts, quick exploration
- User-friendly interface for building queries
- Automatic CONSTRUCT query generation
- Focus on WHERE clause patterns
- Intuitive triple pattern editing
Target Users: SPARQL experts, developers, complex queries
- Full SPARQL query editing with syntax highlighting
- Complete control over query structure
- Support for all SPARQL 1.1 features
- Manual CONSTRUCT template definition
- Triple Pattern Editor: Large text area for WHERE clauses
- LIMIT Control: Slider to set result limit (1-10000)
- Auto-Sync: Changes automatically update Advanced mode
?person foaf:name ?name.
This creates a CONSTRUCT query finding all persons and their names.
?person foaf:name ?name;
foaf:knows ?friend.
Finds persons with both names and friends.
?person foaf:name ?name, ?nickname.
Finds persons with multiple name variants.
?movie dbo:creator ?creator;
rdfs:label ?title.
FILTER(?creator = dbr:Spike_Lee)
Combines pattern matching with value constraints.
Basic mode automatically generates CONSTRUCT queries from your WHERE patterns:
Your Basic Input:
?movie dbo:creator ?creator;
rdfs:label ?title.
FILTER(?creator = dbr:Spike_Lee)Generated CONSTRUCT Query:
CONSTRUCT {
?movie dbo:creator ?creator;
rdfs:label ?title.
}
WHERE {
?movie dbo:creator ?creator;
rdfs:label ?title.
FILTER(?creator = dbr:Spike_Lee)
}
LIMIT 200Use common prefixes directly:
?person foaf:name ?name.
?movie dbo:director dbr:Steven_Spielberg.
Override UI limit in the query text:
?person foaf:name ?name.
LIMIT 50
?book dct:creator ?author;
dct:title ?title;
dct:subject ?topic.
FILTER(?topic = dbc:Literature)
- Full Query Editor: Syntax-highlighted SPARQL editor
- Ace Editor: Professional code editing features
- Manual Control: Complete query customization
CONSTRUCT {
# Template for output triples
?subject ?predicate ?object.
}
WHERE {
# Pattern matching
?subject ?predicate ?object.
}CONSTRUCT {
?person foaf:name ?name;
a foaf:Person.
}
WHERE {
?person foaf:name ?name.
}CONSTRUCT {
?movie dct:title ?title;
dbo:director ?director.
}
WHERE {
?movie a dbo:Film;
dct:title ?title.
OPTIONAL { ?movie dbo:director ?director. }
}CONSTRUCT {
?entity rdfs:label ?label.
}
WHERE {
{ ?entity a dbo:Film; rdfs:label ?label. }
UNION
{ ?entity a dbo:Person; rdfs:label ?label. }
}CONSTRUCT {
?movie dct:title ?title;
:popularity ?rating.
}
WHERE {
{
SELECT ?movie (AVG(?rating) AS ?avgRating)
WHERE {
?movie dbo:gross ?gross.
BIND(?gross / 1000000 AS ?rating)
}
GROUP BY ?movie
}
?movie dct:title ?title.
}CONSTRUCT {
?person foaf:name ?name;
:colleague ?colleague.
}
WHERE {
?person foaf:knows+ ?colleague;
foaf:name ?name.
FILTER(?person != ?colleague)
}PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dbr: <http://dbpedia.org/resource/>
CONSTRUCT {
?person foaf:name ?name.
}
WHERE {
?person foaf:name ?name.
}CONSTRUCT {
?city dbo:populationTotal ?population.
}
WHERE {
?city a dbo:City;
dbo:populationTotal ?population.
}
ORDER BY DESC(?population)
LIMIT 10- Click "Advanced" tab
- Basic WHERE clause converts to full CONSTRUCT query
- All patterns and filters preserved
- LIMIT setting applied
- Click "Basic" tab
- Warning appears if Advanced has custom edits
- WHERE clause extracted from CONSTRUCT query
- Prefixes and complex features may be simplified
- Changes in Basic mode instantly update Advanced
- Advanced changes don't affect Basic (to prevent data loss)
- Manual sync by switching tabs
- Automatic graph generation
- All matched triples visualized
- Literal values included as nodes
- Type relationships shown
- Exact CONSTRUCT template used
- Only specified triples in graph
- More control over visualization
- Can exclude unwanted relationships
- Data Exploration: Quick browsing of datasets
- Simple Queries: Finding entities and properties
- Learning SPARQL: Gradual skill building
- Domain Experts: Focus on content, not syntax
- Complex Queries: UNION, subqueries, property paths
- Performance Tuning: Optimized query patterns
- Custom Visualization: Specific graph structures
- Integration: API-like query construction
- Begin in Basic mode for exploration
- Refine patterns and filters
- Switch to Advanced when needed
- Use Advanced for complex logic
- Use LIMIT in Basic mode for testing
- Apply filters early in patterns
- Consider OPTIONAL vs. required patterns
- Test with small datasets first
- Basic: Prototyping, exploration, simple patterns
- Advanced: Production queries, complex logic, custom output
- Parses triple patterns from text
- Extracts FILTER and other clauses
- Generates minimal CONSTRUCT template
- Handles property paths and complex patterns
- Direct SPARQL execution
- No preprocessing or transformation
- Full SPARQL 1.1 compliance
- User has complete control
- Basic mode: Pattern validation and suggestions
- Advanced mode: Standard SPARQL error reporting
- Cross-mode: Consistent error messaging