Inverse Relations

From Developer Documents
Revision as of 15:55, 28 January 2011 by Juha Kortelainen (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

According to Layer0 semantics, relations can have inverse relations. For the database and client this means that when claiming new statements (s, p, o) using

WriteGraph.claim(Resource subject, Resource predicate, Resource object)

an inverse statement (o, inv(p), s) will be automatically claimed into the database. Some statements are such that they tend to raise the degree of the resource (amount of incoming/outgoing relations) to very large numbers. The database is not built to efficiently handle such resources. One such relation is InstanceOf which is a statement that pretty much each and every resource in the database has. It does not have an inverse relation, but considering it had one like HasInstance, here's what would happen. For example, for each L0.String instance created an inverse statement would be added (L0.String, L0.HasInstance, :L0.String) statement into the database, thereby enlarging the degree of L0.String. When working with larger databases this would most likely become a problem.

To make it possible to optimize this situation we provide the possibility to skip adding of inverse relations when claiming statements into the database by using

WriteGraph.claim(Resource subject, Resource predicate, Resource inverse, Resource object)

with a null inverse relation argument to create the sensitive statements such as InstanceOf-relations.