RDF Database

table of contents

about this document

function interface

piping

Each function takes, as its first argument, an array of triples on which to act. If this argument is NULL, the function acts on the whole database of triples in the database. This is similar to a views in a SQL database, or pipes on a unix command line.

function list:

query functions:

supplied
List all triples supplied by the (user/parser) vs. those created by reification or generated while creating description bags.
all
List all triples with matching predicates, subjects and objects
anySubjects
List all triples with matching subjecs
anyObjects
List all triples with matching objects
anyContainers
List all container triples with matching objects
members
List members of bag ids.
nodesOfType
Find all the nodes of a specific type. Except for the standard RDF types of Alt, Bag, Seq and Statement, these types will originate from typedNodes or as asserted with rdf:type properties.
nodesWithAllPredicates
The nodesWithAllPredicates function compensates for the lack of a grammer and a parser tailored to a specific data schema. Specific parameterization languages can specify things like "An X must also have properties Y and Z or it is invalid". This could be written
X1: Y=2 Z=3
The RDF language defines many ways to express this relation, for instance:
<rdf:Bag Id="B1">
  <li><X ID="X1"/>
</rdf:Bag>
<rdf:Description aboutEach="B1">
  <Y>2</Y>
  <Z>3</Z>
</rdf:Description>
This permits greater flexibility but means an application scanning the RDF database needs a way to search for the valid relations. To find the above, the application may call
triples = DB->nodesWithAllPredicates(DB->nodesWithTypes(NULL, {'X'});
join
Perform vector cross product of listed nodes with listed predicates.

insert functions:

addTriple
Add a triple to the database.
deleteTriple
Remove a triple from the database.
reify
Reify a triple into the database.
createSeq
Create an RDF Sequence container.
createBag
Create an RDF Bag container.
createAlt
Create an RDF Alternative container.
createDescription
Create an RDF Bag container with the added capabilities of storing predicate/object pairs for yet unresolved aboutEachs or aboutEachPrefixs.
registerContainer
Associate a container ID with the container so it can be found when there is an aboutEach or aboutEachPrefix that refers to it.
registerAboutEach
Register a Description as having an aboutEach for a bagID.
registerAboutEachPrefix
Register a Description as having an aboutEachPrefix for a range of bagIDs.
assignId
Get the next unassigned automatically generated ID from the database. It is important that only one source exist for generating IDs or there may be name collisions.

parsing

The RdfParser is separate from the RDF database. Much of the parsing functionality is in the database because I wanted other sources besides the parser to be able to add Triples to the database and take advantage of node id generation and immediate container completion.

node id generation

The RDF database keeps track of the last generated id. A client application adding triples may get ids assigned by the database via the assignId function.

This raises the issue of name collisions.

immediate container completion

In the case of aboutEach and aboutEachPrefix, the subjects of the triples don't arrive at the same time as the predicates and objects. One way to handle this it to gather the predicates and objects related to a bag and cross them with the contents of the bag after parsing is complete.

Since the RDF database may be used in scenarios where the parsing is not completed before the triples are needed, I add triples to the database as soon as they can be known. It does not matter whether the Bag is defined before or after the aboutEach or aboutEachPrefix reference is made.

Bag defined before aboutEach[Prefix]

The RDF database keeps a list of Containers and their bagIDs. If Bag B1 is defined with contents L1, L2 and L3, the created the Description with an aboutEach equal to B1 will get a pointer to the container B1. As predicate/object pairs are added to the Description, they are crossed (multiplied against) each of the subjects in the container B1 so that there is a triple for each combination of subject in the Bag and predicate/object in the Description.

Bag defined after aboutEach[Prefix]

When the Description is created, it registers its aboutEach with the Rdf database. As each Bag that is created, it registers itself with the Rdf database and gets a list of "interested description"s. As each subject is added to the Bag, a triple is created for each combination of that subject with each of the predicate/object pairs in the list of "interested description"s.

Bag defined before, but filled after, aboutEach[Prefix]

If any subject are added to the Bag after the Description has registered its aboutEach, they are caught by the previous mechanism and triples are created for the new subjects with each of the predicate/objects stored in the Description.

related problems

added subjects:
I haven't thought through whether type triples are reliably set for the subjects added to containers. I suspect (and observed in my split Acl example) that it is fine.

conformance

The RdfParser module should handle an legal RDF grammer except:
parseType="Literal" and parseType="Resource".
The propertElt and inlineItem modifiers parseType="Literal", parseType="Resource" and subClassOf are not supported.
name collisions
There are no provisions to make sure that have already been assumed by the application are not issued by assignId.
testing
RdfParser and RdfDB need serious testing.
added subjects
see discussion above. I say should as the other serious conformance shortcoming is testing. If you have this package, please consider this an alpha and not an authority on what triples get generated from what RDF. Also, please notify me (eric@w3.org) if/when you find mistakes.

freaky features

attributions

Attributions are an experimental way to keep track of which triples are trusted and why they're trusted. The implementation is currently just a sketch.