Object Reference Integrity

http://sourceforge.net/tracker/index.php?func=detail&aid=1868068&group_id=179124&atid=887888

NeoDatis ODB does not implement Object Reference Integrity. So, if a user has an attribute profile, ODB allows deleting the profile leaving the user object in a 'strange' state. Where fetching the user object, the profile attribute will be nulled.

The aim of the Object Reference Integrity feature is to avoid deleting the profile object for being referenced by another object. It would be a kind of implicit foreign key for relations.

vocabulary

  • object
  • reference holder

example: a class User has a Profile
class User(
String name
Profile profile
)

The profile is the object being referenced and will be called the object.
The user is the reference holder to the profile.

4 strategies

Strategy 1

Each object maintains a counter of the number of reference held by other objects
- this counter must be updated on every operations insert, update, delete

This strategy only saves the number of reference holders. It will not be able to point the reference holder of a specific object.

Strategy 2

Each object maintains a pointer to an Object Reference block that holds object reference informations. This would be a new block type.

Strategy 3

A new system class is created (object reference) to hold the reference informations. This solution would allow to keep all references details. The object reference class must have the following attributes:
- oid: object being referenced(oid)
- referenceHolderOid : object holding reference(oid)
- timestamp : creation date time

this class must be indexed on the oid field to enable fast reference discovering.

Strategy 4 : Direct index

Oracle needs to define a foreign key to enable this functionality. The foreign key explicitly describes the relation between two fields of two tables. And when the constraint is violated, Oracle displays the constraint being violated.

To implement this in ODB, we could create a btree index where the key is the object oid, and the value is the reference holder oid.

This btree will point to object oid,

problems:

  • What if a reference holder object is being deleted. Could be resolved in lazy mode. When finding the reference, if reference holder is deleted, delete the btree index entry
  • How to manage object update when changing object reference: update the profile of a user : the old reference should be deleted and the new one should be created. It can be done using the old meta object that has the old profile oid to search the reference btree and to delete. The insert will automatically create the object reference.
  • Things to implement in ODB core before:

- btree with non unique keys

Conclusion

The third and fourth strategies allow a very detailed information about references as it can tell the holder reference oid whereas the first two only hold the number of references.

page_revision: 2, last_edited: 1203971824|%e %b %Y, %H:%M %Z (%O ago)
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License