Adds the value of one attribute to the value of another attribute, if you are inserting.
Subtracts the value of one attribute to the value of another attribute, if you are deleting.
Calculates the difference between the new and old value of the attribute you update and that difference is added to another attribute if you are updating.
Add(att1 , att2) [ if cond ] ;
In mode:
- Insert: the value of the att1 attribute is added to the value of the att1 attribute (if the specified condition is true).
- Delete: the value of the att1 attribute is subtracted from the value of the att2 attribute (if the specified condition is true).
- Update: the difference between the new and old value of the att1 attribute is added to the value of the att2 attribute (if the specified condition is true).
Consider the following Transaction objects:
Customer Trip Country
{ { {
CustomerId* TripId* CountryId*
CustomerName TripDate CountryName
CustomerLastName CountryId City
CustomerPhone CountryName {
CustomerTotalMiles CityId CityId*
Trip CityName CityName
{ TripMiles }
TripId* }
TripDate }
CountryId
CountryName
CityId
CityName
TripMiles
}
}
Suppose that a customer makes several trips and accumulates miles.
To implement the customer’s mileage accumulation, you define the following rule in the Customer Transaction:
Add(TripMiles, CustomerTotalMiles);
The following behavior is incorporated into the Add rule:
- If a new trip is added for the customer, the value of TripMiles is added to CustomerTotalMiles.
- If a trip is deleted from the customer, the value of TripMiles is subtracted from CustomerTotalMiles.
- If the value of TripMiles associated with a customer’s trip is changed, its configured value is automatically subtracted and the new value is added to the customer’s total miles.
Subtract rule