NAME

RDF::RDB2RDF::DirectMapping - map relational database to RDF directly

SYNOPSIS

my $mapper = RDF::RDB2RDF->new('DirectMapping',
  prefix => 'http://example.net/data/');
print $mapper->process_turtle($dbh);

DESCRIPTION

This module makes it stupidly easy to dump a relational SQL database as an RDF graph, but at the cost of flexibility. Other than providing a base prefix for class, property and instance URIs, all mapping is done automatically, with very little other configuration at all.

This class offers support for the W3C Direct Mapping, based on the 20 Sept 2011 working draft.

Constructor

  • RDF::RDB2RDF::DirectMapping->new([prefix => $prefix_uri] [, %opts])

  • RDF::RDB2RDF->new('DirectMapping' [, prefix => $prefix_uri] [, %opts])

The prefix defaults to the empty string - i.e. relative URIs.

One extra option is supported: rdfs which controls whether extra Tbox statements are included in the mapping.

Methods

  • process($source [, $destination])

    Given a database handle, produces RDF data. Can optionally be passed a destination for triples: either an existing model to add data to, or a reference to a callback function.

    $source can be a DBI database handle, or an arrayref pair of a handle plus a schema name.

    $destination = sub {
      print $_[0]->as_string . "\n";
    };
    $dbh    = DBI->connect('dbi:Pg:dbname=mytest');
    $schema = 'fred';
    $mapper->process([$dbh, $schema], $destination);

    Returns the destination.

  • process_turtle($dbh, %options)

    As per process, but returns a string in Turtle format.

    Returns a string.

SEE ALSO

RDF::Trine, RDF::RDB2RDF.

http://perlrdf.org/.

http://www.w3.org/TR/2011/WD-rdb-direct-mapping-20110920/.

AUTHOR

Toby Inkster <tobyink@cpan.org>.

COPYRIGHT

Copyright 2011 Toby Inkster

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.