Društvo LJUDMILA
Rozmanova ulica 12
1000 Ljubljana
Slovenia
Prostori: osmo/za

URIs of Database Objects

To interoperate with RDF, we need URIs for the following:

each schema:

http://example.org/schema/schema

each table:

http://example.org/schema/schema/table

each table column:

http://example.org/schema/schema/table/column

each record:

http://example.org/data/schema/table/primary-key

(maybe) each column in each record:

http://host/data/schema/table/primary-key/column

Bold values signify identifiers.

For convenience we define two namespaces for each host, one to represent the database schema and one to represent the actual data. You can reuse the schema namespace for several data stores, provided they agree or at least don't conflict in layout. Each separate database server should have its own data namespace.

xmlns:schema="http://example.org/schema/"
xmlns:data="http://example.org/data/"

Note: URIs should ideally not change with time, ever, not even when the content is edited.

Escaping identifiers

The many identifiers used here need to be escaped into friendly urls.

Characters that need to be escaped:

. _ / ? # %

any more?

Escape pattern:

.hh. - each h is one hex digit of byte [0-9a-f]

Composite Primary Keys

Escape each PK value in key order with this algorithm, then join them using _ (underscore). This will get you a unique and URL compliant path segment. To parse this back, split on underscore and unescape each value in turn.

Perl Code

sub esc_urli {
  $_ = shift;
  s/\./.2e./g;
  s/\#/.23./g;
  s/%/.25./g;
  s/\//.2f./g;
  s/\?/.3f./g;
  s/_/.5f./g;
  return $_;
}
sub unesc_urli {
  $_ = shift;
  s/\.5f\./_/g;
  s/\.3f\./\?/g;
  s/\.2f\./\//g;
  s/\.25\./%/g;
  s/\.23\./#/g;
  s/\.2e\./\./g;
  return $_;
}
sub esc_pkuri {
  return join('_', (map {esc_urli($_)} @_));
}
sub unesc_pkuri {
  my @a=map {unesc_urli($_)} split('_',shift);
  return \@a;
}