Skip to content

UserGuide Configuration Triple Stores

Kal edited this page Jan 17, 2020 · 16 revisions

Home > User Guide > Configuration API > Triple Stores

Configuration Triple Stores

Triple Stores can be specified using the Configuration Vocabulary in a number of ways. The ConfigurationLoader is capable of loading a variety of types of Triple Store from configuration.

Triple Stores are loaded from configuration in the following way:

  1. Create an instance of the relevant ITripleStore implementation based on the dnr:type property
  2. Any automated loading that the implementation does starts occurring now
  3. Read in any data sources in the following order
    1. Graphs
    2. Dataset Files
  4. Apply reasoners

Basic Configuration

At it's most basic a Triple Store is configured as follows:

@prefix dnr: <http://www.dotnetrdf.org/configuration#> .

_:store a dnr:TripleStore ;
  dnr:type "VDS.RDF.TripleStore" .

Data Source Configuration

There are only 2 ways to specify Graphs to be loaded into a Triple Store but since 1 of these is from other Graphs specified in the configuration file you can actually use any of the data sources supported by Graphs as described in Configuration API - Graphs.

Other Graphs

Using the dnr:usingGraph property any number of Graphs can be loaded into a Triple Store. Note that each graph must have a unique Base URI or the Triple Store will throw an error, as described in Configuration API - Graphs you can use the dnr:assignUri property to ensure this.

The following example shows loading two graphs into a Triple Store

@prefix dnr: <http://www.dotnetrdf.org/configuration#> .

_:store a dnr:TripleStore ;
  dnr:type "VDS.RDF.TripleStore" ;
  dnr:usingGraph _:a ;
  dnr:usingGraph _:b .

_:a a dnr:Graph ;
  dnr:type "VDS.RDF.Graph" ;
  dnr:fromFile "example.rdf" .

_:b a dnr:Graph ;
  dnr:type "VDS.RDF.Graph" ;
  dnr:fromUri <http://dbpedia.org/resource/Southampton> .

Dataset Files

You can populate a Triple Store using a RDF dataset file which is in one of the dataset formats dotNetRDF understands (NQuads, TriG or TriX) which you specify with the dnr:fromFile property. File paths can either be absolute or may be relative. In the case of relative paths the resolution of the path can be controlled by introducing an IPathResolver implementation by setting the PathResolver property of the ConfigurationLoader.

The following example loads a dataset from a file:

@prefix dnr: <http://www.dotnetrdf.org/configuration#> .

_:store a dnr:TripleStore ;
  dnr:type "VDS.RDF.TripleStore" ;
  dnr:fromFile "example.trig" .

Applying Reasoners

You can also apply reasoners to Triple Stores loaded in this way with the triples that the reasoner produces being materialised into a special Graph in the Triple Store. To learn how to configure a reasoner see Configuration API - Reasoners.

Linking a reasoner to a Triple Store is as easy as using the dnr:reasoner property as the following example in which an RDF Schema reasoner is applied to the Triple Store.

@prefix dnr: <http://www.dotnetrdf.org/configuration#> .

_:store a dnr:TripleStore ;
  dnr:type "VDS.RDF.TripleStore" ;
  dnr:reasoner _:rdfs .

_:rdfs a dnr:Reasoner ;
  dnr:type "VDS.RDF.Query.Inference.RdfsReasoner" .

When you apply a reasoner to a Store then that reasoner gets applied over all existing Graphs in the Store and then if any additional Graphs are added to the Store the reasoner gets applied to newly added Graphs.

Configuring Complex Triple Stores

It is possible to configure a number of more complex ITripleStore instances beyond the basic TripleStore demonstrated so far. This section of the document describes additional types of Triple Store that can be configured.

Web Demand Triple Store

The WebDemandTripleStore is a Triple Store which attempts to load Graphs from the web whenever a Graph with a URI which is not currently in the Store is requested. Configuring this is as simple as altering the value of the dnr:type property like so:

@prefix dnr: <http://www.dotnetrdf.org/configuration#> .

_:store a dnr:TripleStore ;
  dnr:type "VDS.RDF.WebDemandTripleStore" .

Persistent Triple Store

The PersistentTripleStore provides a view of an arbitrary store for which there is an IStorageProvider provided. The Triple Store can then be used for query and update operations on the underlying store. This is configured by setting the dnr:type property appropriately and then using the dnr:storageProvider property to point to a storage provider to be used e.g.

@prefix dnr: <http://www.dotnetrdf.org/configuration#> .

_:store a dnr:TripleStore ;
  dnr:type "VDS.RDF.PersistentTripleStore" ;
  dnr:storageProvider _:agraph .

_:agraph a dnr:StorageProvider ;
  dnr:type "VDS.RDF.Storage.AllegroGraphConnector" ;
  dnr:server "http://localhost:9875" ;
  dnr:catalogID "catalog" ;
  dnr:storeID "repository" .

Basic Tutorial

  1. Getting Started
  2. Library Overview
  3. Hello World
  4. Reading RDF
  5. Writing RDF
  6. Working With Graphs
  7. Typed Values and Lists
  8. Working with Triple Stores
  9. Building SPARQL
  10. Querying with SPARQL
  11. Updating with SPARQL
  1. Exceptions
  2. Equality and Comparison
  3. Event Model
  4. Utility Methods
  5. Extension Methods
  6. Using the Namespace Mapper
  7. Storage API
    1. Triple Store Integration
    2. Storage Providers
    3. Servers API
    4. Transactions API
  8. Advanced SPARQL
    1. Result Formatting
    2. SPARQL Datasets
    3. Full Text Querying with SPARQL
    4. Advanced SPARQL Operations
  9. Ontology API
  10. Inference and Reasoning
  11. ASP.NET Integration
    1. Creating SPARQL Endpoints
    2. Deploying with rdfWebDeploy
  12. Global Options
  13. Dynamic API
  14. Formatting API
  15. Configuration API
    1. Graphs
    2. Triple Stores
    3. Object Factories
    4. Readers and Writers
    5. SPARQL Endpoints
    6. Query Processors
    7. Update Processors
    8. Protocol Processors
    9. SPARQL Datasets
    10. SPARQL Expression Factories
    11. SPARQL Operators
    12. SPARQL Optimisers
    13. Full Text Query
    14. Reasoners
    15. Storage Providers
    16. User Groups
    17. Permissions
    18. Users
    19. Static Options
    20. Proxy Servers
  16. Handlers API
  17. JSON-LD API
  18. Tools
    1. rdfConvert
    2. rdfEditor
    3. rdfOptStats
  1. Architecture
  2. Design
  3. Namespaces
  4. SPARQL Engine
  5. SPARQL Optimization
  6. Implementing Custom Optimizers
  7. SPARQL Extensions
  8. SPARQL Performance
  9. URI Interning
  10. Notes for Silverlight and WP7 Developers
  11. Developing for dotNetRDF
  12. Compiling
  13. Code Style
  14. Deprecation Policy
  15. Test Environment
  1. Debug HTTP Communication
  2. Debug SPARQL Queries
  3. Load OWL
  4. Load RDF from a File
  5. Load RDF from the Web
  6. Minimize Memory Usage
  7. Reify Triples
Clone this wiki locally