# DBPedia

## GraphIRI

This is the graph identifier (URI):

`http://dbpedia.org`

## History of queries

```SQL
PREFIX dbo:  <http://dbpedia.org/ontology/>
PREFIX dbp:  <http://dbpedia.org/property/>
PREFIX dbr:  <http://dbpedia.org/resource/>

SELECT ?subject, ?relationship, ?object
WHERE {
  ?subject ?relationship ?object .
  {
    SELECT ?object
    WHERE {
      ?m rdf:type dbo:Film .
      ?object ?r ?m
    }
  }
}
```

### 2 Hops

```SQL
PREFIX dbo:  <http://dbpedia.org/ontology/>
PREFIX dbp:  <http://dbpedia.org/property/>
PREFIX dbr:  <http://dbpedia.org/resource/>

SELECT ?subject, ?relationship, ?object
WHERE {
  ?subject ?relationship ?object .
  FILTER (?relationship != <http://dbpedia.org/ontology/wikiPageWikiLink>)
  {
    SELECT ?object
    WHERE {
      ?m rdf:type dbo:Film .
      ?object ?r ?m
      FILTER (?r != <http://dbpedia.org/ontology/wikiPageWikiLink>)
    }
  }
}
LIMIT 1000000
```

### 1 Hop

```SQL
PREFIX dbo:  <http://dbpedia.org/ontology/>
PREFIX dbp:  <http://dbpedia.org/property/>
PREFIX dbr:  <http://dbpedia.org/resource/>

SELECT ?subject, ?relationship, ?object
WHERE {
  ?subject ?relationship ?object .
  ?object rdf:type dbo:Film .
  FILTER (?relationship != <http://dbpedia.org/ontology/wikiPageWikiLink>)
}
LIMIT 1000000
```

```SQL
PREFIX dbo:  <http://dbpedia.org/ontology/>
PREFIX dbp:  <http://dbpedia.org/property/>
PREFIX dbr:  <http://dbpedia.org/resource/>

SELECT ?subject, ?relationship, ?object
WHERE {
  ?subject ?relationship ?object .
  ?subject rdf:type dbo:Film .
}
```

```SQL
PREFIX dbo:  <http://dbpedia.org/ontology/>
PREFIX dbp:  <http://dbpedia.org/property/>
PREFIX dbr:  <http://dbpedia.org/resource/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>

SELECT ?subject, ?relationship, ?object
WHERE {
  ?subject ?relationship ?object .
  ?subject rdf:type dbo:Film .
  ?a foaf:primaryTopic ?subject
}
```

```SQL
PREFIX dbo:  <http://dbpedia.org/ontology/>
PREFIX dbp:  <http://dbpedia.org/property/>
PREFIX dbr:  <http://dbpedia.org/resource/>

SELECT ?subject
WHERE {
  ?subject rdf:type dbo:Film .
}
```

```SQL
PREFIX dbo:  <http://dbpedia.org/ontology/>
PREFIX dbp:  <http://dbpedia.org/property/>
PREFIX dbr:  <http://dbpedia.org/resource/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>

SELECT ?subject
WHERE {
  ?subject rdf:type dbo:Film .
  ?a foaf:primaryTopic ?subject
}
```

```SQL
PREFIX dbo:  <http://dbpedia.org/ontology/>
PREFIX dbp:  <http://dbpedia.org/property/>
PREFIX dbr:  <http://dbpedia.org/resource/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>

SELECT ?subject, ?relationship, ?object
WHERE {
  ?subject ?relationship ?object .
  ?subject rdf:type dbo:Film .
  ?a foaf:primaryTopic ?subject
  FILTER (?relationship NOT IN (
    dbo:wikiPageRedirects,
    dbo:wikiPageExternalLink,
    dbo:wikiPageWikiLink,
    foaf:primaryTopic
  ))
}

```

#### Wikipedia-movie

a.k.a the file with the wikipedia abstract

```SQL
PREFIX dbo:  <http://dbpedia.org/ontology/>
PREFIX dbp:  <http://dbpedia.org/property/>
PREFIX dbr:  <http://dbpedia.org/resource/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>

SELECT  ?subject , ?object
WHERE {
  ?subject foaf:primaryTopic ?object .
  ?object rdf:type dbo:Film 
}
```

#### Reverse

```SQL
PREFIX dbo:  <http://dbpedia.org/ontology/>
PREFIX dbp:  <http://dbpedia.org/property/>
PREFIX dbr:  <http://dbpedia.org/resource/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>

SELECT ?subject, ?relationship, ?object
WHERE {
  ?subject ?relationship ?object .
  ?object rdf:type dbo:Film .
  ?a foaf:primaryTopic ?object
  FILTER (?relationship NOT IN (
    dbo:wikiPageRedirects,
    dbo:wikiPageExternalLink,
    dbo:wikiPageWikiLink,
    foaf:primaryTopic
  ))
}
```

```SQL
PREFIX dbo:  <http://dbpedia.org/ontology/>
PREFIX dbp:  <http://dbpedia.org/property/>
PREFIX dbr:  <http://dbpedia.org/resource/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>

SELECT ?subject, ?relationship, ?object
WHERE {
  ?subject ?relationship ?object .
  ?object rdf:type dbo:Film .
  ?a foaf:primaryTopic ?object
  FILTER (?relationship NOT IN (
    dbo:wikiPageRedirects,
    dbo:wikiPageExternalLink,
    dbo:wikiPageWikiLink,
    foaf:primaryTopic
  ))

```

#### Film \ wiki page ID

```SQL
PREFIX dbo:  <http://dbpedia.org/ontology/>
PREFIX dbp:  <http://dbpedia.org/property/>
PREFIX dbr:  <http://dbpedia.org/resource/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?subject ?pageID
WHERE {
  ?subject rdf:type dbo:Film .
  ?subject dbo:wikiPageID ?pageID .
  ?subject rdfs:label ?label .
  FILTER (lang(?label) = "en")
}

```
