## QuickStart

On this page we give a brief overview over SPARQL and demonstrate a very simple use case of Symbolic Data.

Please post all questions about using SymbolicData Tools and Data on the SymbolicData Mailing List

To better understand the query on this page it helps to know that the data is stored as so called triples. A triple consist of a subject, a predicate and an object. Note that these terms are used rather loosely and not adhering to natural language grammar rules. Examples are:

• PS10 ­— is a — Polynomial System
• PS10 — has degree of — 18
• Group1 — has group order — 2\^2*3\^3

### Using SPARQL to retrieve data

A SPARQL request always yields (not necessarily distinct) assignments to a set of variables. The variables are listed after the SELECT command:

```  SELECT ?a ?b ?c …
```

or, if only distint assignments are wanted:

```  SELECT DISTINCT ?a ?b ?c …
```

Generally we don’t want all possible assignments but only assigments that satisfy certain conditions. This can be written like this:

```  SELECT ?a ?b ?c WHERE {
condition1 .
condition2 .
condition3
}
```

The dot here stands for a logical ‘and’. These conditions may also introduce additional variables where it is convenient. There are also more elaborate methods to extract exactly the things you want but we concentrate on this simple method at first.

To test the following queries yourself, go to http://symbolicdata.org:8890/sparql or try the given link directly.

### Examples

1) Let’s search all triples and see what predicates are used to get a general idea about the data:

```  SELECT DISTINCT ?p WHERE {
?s ?p ?o
}
```

This will extract the predicate of all triples. Since a given predicate usually is used in a lot of sentences we indicate that we want a list of distinct values.

NB: This list does not contain a lot information. Usually additional information is given in a documentation. For the polynomial systems you can find it here: http://symbolicdata.github.io/PolynomialSystems.Ontology

2) To retrieve all possible values (‘objects’) to a given predicate :

```  SELECT DISTINCT ?v WHERE {
?s <pred> ?v
}
```

These values could be used to fill a pull down menu using PHP, but depending on the the number of values this might be useful or not.

3) Display Integer Polynomial Systems (‘a’ is a shortcut for the predicate ‘rdf:type’)

```  PREFIX sd: <http://symbolicdata.org/Data/Model#>
SELECT ?s WHERE {
?s a sd:Ideal
}
```

Run this query

4) Display all Integer Polynomial Systems of degree 20 (‘^^xsd:integer’ ist eine Typergänzung für das Literal “20” und sagt SPARQL, dass dieser String als Integer zu interpretieren ist)

```  PREFIX sd: <http://symbolicdata.org/Data/Model#>
SELECT ?s WHERE {
?s a sd:Ideal .
?s sd:hasDegree "20"^^xsd:integer .
}
```

Run this query

```  PREFIX sdpol: <http://symbolicdata.org/Data/Ideal/>
SELECT ?p ?o WHERE {
sdpol:Caprasse ?p ?o
}
```

Run this query

You might noticed that there are some values where there the object is quite complex, like for instance the variable list with values like “x,y,z,t”. One could also parse these values (e.g. do a regex match on them, all within a SPARQL query). But maybe these values turn out to be so important that you don’t want to parse them but rather query them directly. In this case the data could easily be modified (but we’re not going into detail here).

6) Getting a table-like display of all entries can also be done:

```  PREFIX sd: <http://symbolicdata.org/Data/Model#>
SELECT ?a ?dim ?deg ?ll WHERE {
?a a sd:Ideal .
?a sd:hasDimension ?dim .
?a sd:hasDegree ?deg .
?a sd:hasLengthsList ?ll
}
```

Run this query

This query could be send as HTTP request and then rendered into a HTML table by a quite simple PHP script. (Details on this will be included later)

For some polynomial systems there is no dimension specified. The previous query does not find these. You can fix this by giving the condition on dimension an optional modifier:

```  PREFIX sd: <http://symbolicdata.org/Data/Model#>
SELECT ?a ?dim ?deg ?ll WHERE {
?a a sd:Ideal .
OPTIONAL {?a sd:hasDimension ?dim} .
?a sd:hasDegree ?deg .
?a sd:hasLengthsList ?ll
}
```

Run this query

Now suppose we want to work with precisely the polynomial system that are missing a dimension. Here we could filter the result:

```  PREFIX sd: <http://symbolicdata.org/Data/Model#>
SELECT ?a ?dim ?deg ?ll WHERE {
?a a sd:Ideal .
OPTIONAL {?a sd:hasDimension ?dim} .
?a sd:hasDegree ?deg .
?a sd:hasLengthsList ?ll .
FILTER(!BOUND(?dim))
}
```

Run this query

If we want not just degree 20 but a degree within a certain range, it is useful to introduce a variable ?d for the degree and include another condition for the variable ?d.

```  PREFIX sd: <http://symbolicdata.org/Data/Model#>
SELECT ?s ?d WHERE {
?s a sd:Ideal .
?s sd:hasDegree ?d .
FILTER(xsd:integer(?d) <= 20)
}
```

Run this query