Link Search Menu Expand Document
Start for Free

Data Catalog

This chapter discusses the Data Catalog and how to use it.

Page Contents
  1. Overview
  2. Configuration Options
  3. Usage
    1. Data Model Classes
    2. Example SPARQL Queries
    3. Data Source Linking
    4. Explorer
    5. Explorer Advanced Query

Overview

The Data Catalog allows users to query virtual graph and data source metadata using SPARQL. The Data Catalog is enabled by default. It watches for changes to virtual graphs and data sources and adds or updates the related metadata in the catalog database.

The Data Catalog automatically creates a catalog database when it starts. Set the catalog.database server property to use a different name or prevent the Data Catalog from using an existing database named catalog.

To prevent the Data Catalog database from being created automatically set catalog.auto.create.db to false.

Configuration Options

The Data Catalog can be configured with the following options in stardog.properties:

Option Description Value Default
catalog.database Name of the database to use for storing catalog metadata. If this database does not exist one will be automatically created. string catalog
catalog.name Name of the IRI used for the catalog named graph. string local
catalog.reload.onstart If true any existing catalog data will be dropped and all data sources and virtual graphs metadata will be loaded on server start. When false only new metadata will be captured after server start. true/false false
catalog.auto.create.db If false then the catalog database will not be created automatically at server start if it does not already exist. true/false true

Usage

The capture and storage of Stardog metadata happens automatically and without user interaction. The user facing feature of the Data Catalog are SPARQL queries and Explorer for visual exploration of metadata. The new Explorer advanced query feature can also be used to query the metadata model.

To query only for metadata, SPARQL queries are run against the catalog database. To query for metadata in addition to another database the local database service can be used.

Data Model Classes

This table contains the classes used for modeling the Data Catalog metadata.

Class Description
dcat:Catalog Top level class for all metadata
dcat:Dataset A collection of data available for access in one or more representations
tag:stardog:api:catalog:DataSource A distribution of a data source
tag:stardog:api:catalog:Schema The tables that are part of a data source
tag:stardog:api:catalog:Table A single table
tag:stardog:api:catalog:Column A table column
tag:stardog:api:catalog:VirtualGraph The configuration for a virtual graph
tag:stardog:api:catalog:Mapping Mappings of tables to RDF

Example SPARQL Queries

The following are some query examples that demonstrate how virtual graph metadata can be queried.

  • What catalogs are available?
      prefix dcterms: <http://purl.org/dc/terms/>
      prefix dcat: <http://www.w3.org/ns/dcat#>
      select ?src ?lbl where {
          graph <tag:stardog:api:catalog:local> {
          ?src a dcat:Catalog ; dcterms:title ?lbl
      }}
    
  • What datasets are in the catalog?
      prefix dcterms: <http://purl.org/dc/terms/>
      prefix dcat: <http://www.w3.org/ns/dcat#>
      select ?ds where {
          graph <tag:stardog:api:catalog:local> {
          ?src a dcat:Catalog ; dcat:dataset ?ds .
      }}
    
  • Query for all table columns across all datasets
      prefix : <tag:stardog:api:catalog:>
      select *
      from stardog:context:local 
      where {
          ?t a :Table ;
             :hasColumn ?c .
          ?c :columnName ?n .
      } 
    
  • Dump the contents of a catalog
      prefix : <tag:stardog:api:catalog:>
      prefix rr: <http://www.w3.org/ns/r2rml#>
      select * 
      from stardog:context:local
      where {
          ?ds a :DataSource ;
              :hasCatalog ?cata .
          ?cata :hasTable ?table .
          ?table :hasColumn ?column .
          ?vg :connectsTo ?ds ;
              :hasMapping ?map .
          ?map rr:predicateObjectMap ?pomap .
          ?pomap rr:objectMap ?omap ;
              rr:predicateMap ?predmap .
          ?omap rr:column ?col .
          ?omap rr:datatype ?dtype .
          ?predmap rr:constant ?con .
          ?fld rr:logicalTable ?logtbl .
          ?logtbl rr:tableName ?tblname .
          ?fld rr:subjectMap ?subjmap .
          ?subjmap rr:template ?template ;
              rr:termType ?termtype .
      }
    

Data Source Linking

When data sources and virtual graphs are added to the Data Catalog, their source data and graph maps are scanned for table and column references. Those references are then linked together through a tag:stardog:api:catalog:mapsColumn attribute.

This can be useful information for finding how a triple is mapped to an external database and which tables and columns were used.

  • Example query to see all mapped columns:
      select * 
      from stardog:context:local {
          ?s stardog:catalog:mapsColumn ?o .
      }
    
  • Example path query from a known predicate to its mapping:
      PATHS shortest
      from stardog:context:local
      start ?s = <http://example.org/comvendor#nr>
      end ?e = <tag:stardog:api:catalog:bsbm:benchmark:vendor:nr>
      via {
          ?pomap <http://www.w3.org/ns/r2rml#constant> ?s ;
                 stardog:catalog:mapsColumn ?e .
      }
    

Explorer

After you have Data Catalog configured and running on your server you can log into Explorer and select your catalog database to begin exploring.

Explorer caches the catalog data when you log in. If you make virtual graph changes in Studio or on the command line you will need to refresh Explorer to see the changes.

Explorer Advanced Query

Properties have been added to enable the new Explorer advanced query functionality with Data Catalog.