Deltas are data structures that describe relative change. Deltas describe how a thing should be modified. It does rely on how the thing looked before the change or how it will look after the change. Delta describes only what was changed.

There are several types of deltas. The basic difference is about the thing is changing:

A picture is worth a thousand words therefore next sections provide examples of the most common delta types.

Object ADD Delta

Object ADD delta is adding a new object. It contains a complete representation of new object to be added.

The diagram above illustrates the application of ADD delta. The object did not exist before delta application. The delta contains an object that should be added. When the delta is executed a new object is created that is an copy of the object specified in the delta.

The object provided in the delta may or may not have OID. If it does then that OID will be used. If it does not then it will be generated when the delta is executed. The ADD object delta obviously works only if such object does not exist already. Attempt to apply ADD delta to an existing objects results in an error.

<objectDelta>
    <changeType>add</changeType>
    <objectType>c:UserType</objectType>
    <objectToAdd>
        <c:user>
            <c:name>jack</c:name>
            ...
        </c:user>
    </objectToAdd>
</objectDelta>

Object MODIFY Delta

TODO

Object MODIFY:add Delta

<objectDelta>
    <changeType>modify</changeType>
    <objectType>c:UserType</objectType>
    <oid>e3ba0a70-6ef3-11e2-8c1f-001e8c717e5b</oid>
    <modification>
        <modificationType>add</modificationType>
        <value>
            <c:employeeType>pirate</c:employeeType>
        </value>
    </modification>
</objectDelta>

Object MODIFY:delete Delta

<objectDelta>
    <changeType>modify</changeType>
    <objectType>c:UserType</objectType>
    <oid>e3ba0a70-6ef3-11e2-8c1f-001e8c717e5b</oid>
    <modification>
        <modificationType>delete</modificationType>
        <value>
            <c:employeeType>pirate</c:employeeType>
        </value>
    </modification>
</objectDelta>

Object MODIFY:replace Delta

<objectDelta>
    <changeType>modify</changeType>
    <objectType>c:UserType</objectType>
    <oid>e3ba0a70-6ef3-11e2-8c1f-001e8c717e5b</oid>
    <modification>
        <modificationType>replace</modificationType>
        <value>
            <c:fullName>cpt. Jack Sparrow</c:fullName>
        </value>
    </modification>
</objectDelta>

Complex Object MODIFY Delta

TODO: show how to use several item deltas in a single object delta

Object DELETE Delta

Object DELETE delta is deleting an existing object. It contains just an OID and a type of an object to delete.

The diagram above illustrates the application of DELETE delta. An object did exist before delta application. The delta contains OID and type of the object. When the delta is executed the object is deleted and it no longer exists.

The DELETE object delta obviously works only if such object does exist. Attempt to apply DELETE delta to an non-existing objects results in an error.

<objectDelta>
    <changeType>delete</changeType>
    <objectType>c:UserType</objectType>
    <oid>e3ba0a70-6ef3-11e2-8c1f-001e8c717e5b</oid>
</objectDelta>