<?xml version='1.0' ?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
               "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
<!ENTITY % myvars SYSTEM "../variables.ent">
%myvars;
]>
<sect1 id="object-identity" xreflabel="Object Identity">
<title>Object Identity</title>


<authorblurb>
<para>By <ulink url="http://planitia.org">Rafael H. Schloming</ulink></para>
</authorblurb>


<para>One of the major design features of OpenACS &version; is the explicit representation
of <emphasis>object identity</emphasis>. The reason I say &quot;explicit
representation&quot; is because the concept of object identity has been
around forever. It is inherent to our problem domain. Consider the example of
3.x style scoping. The 3.x data models use the triple (user_id, group_id,
scope) to <emphasis>identify</emphasis> an <emphasis>object</emphasis>. In the &version; data model this
object is <emphasis>explicitly represented</emphasis> by a single party_id.</para>

<para>Another good example of this is can be found in the user groups data
model. The 3.x user groups data model contains another example of an
<emphasis>implied identity</emphasis>. Every mapping between a user and a group could
have an arbitrary number of attached values (user_group_member_fields, etc.).
In this case it is the pair (group_id, user_id) that implicitly refers to an
object (the person&#39;s membership in a group). In the &version; data model this
object identity is made explicit by adding an integer primary key to the
table that maps users to groups.</para>

<para>Coming from a purely relational world, this might seem slightly weird at
first. The pair (group_id, user_id) is sufficient to uniquely identify the
object in question, so why have the redundant integer primary key? If you
take a closer look, it actually isn&#39;t quite so redundant. If you want to
be able to use the object model&#39;s permissioning features, and generic
attribute features on a table, you need an integer primary key for that
table. This is because you can&#39;t really write a data model in oracle that
uses more than one way to represent identity.</para>

<para>So, this apparently redundant primary key has saved us the trouble of
duplicating the entire generic storage system for the special case of the
user_group_map, and has saved us from implementing ad-hoc security instead of
just using acs-permissions. This design choice is further validated by the
fact that services like journals that weren&#39;t previously thought to be
generic can in fact be generically applied to membership objects, thereby
allowing us to eliminated membership state auditing columns that weren&#39;t
even capable of fully tracking the history of membership state.</para>

<para>The design choice of explicitly representing object identity with an
integer primary key that is derived from a globally unique sequence is the
key to eliminating redundant code and replacing it with generic <emphasis>object
level services</emphasis>.</para>

<para><phrase role="cvstag">($Id: object-identity.xml,v 1.7 2006/07/17 05:38:37 torbenb Exp $)</phrase></para>

</sect1>
