Container components

Container components provide a way to create a data structure similar to a database table in your trigger systems. You use the Container to define the table that holds the data inserted by a Container Manipulator.

Optionally, you can also define the following.

  • The aggregation, or database function, applied to each field in the table
  • The number of records that are retained and how long to retain them

The Container never fires an event.

Container usage

Containers can store data from multiple data sources. A single Container can also be used by multiple trigger systems.

Multiple data sources

Here is an example of a trigger system with a Container that holds data from two data sources. Suppose you have transaction data from two channels: your web site and in-store purchases. Fields in the data from each channel may differ, but both channels include the following fields.

  • date of purchase
  • SKU number
  • quantity
  • price

You could use a single Container to hold data from both feeds, and use this Container in a trigger system designed to respond when a customer's activity declines. The trigger system illustrated by the following diagram evaluates the average customer spending from two time periods, and responds when spending decreases.


Diagram illustrating a workspace with a Container holding data from two data sources.

Multiple trigger systems

Containers can be designed to be useful within a single trigger system, or across multiple trigger systems. For example, a Container could be limited to hold information on only the color and size of garments a customer purchases. You might draw data from this Container for use within a single trigger system.

In contrast, you could define a Container that holds as much data as is required across all the trigger systems that will use it, and then share the Container across trigger systems.

You should consider processing efficiency when deciding whether to create a limited or broad Container. Containers that are expected to hold a very high number of records should generally limit the number of fields per record.

Types of data that a Container can hold

The fields you define in Container components can hold any of the following data types.

  • Boolean
  • Currency
  • Date
  • Double
  • Integer
  • String

Table Definition

For each field you want to define, you select a data type and an aggregation function to apply to the field. You also give the field a name.

In a Container Manipulator, you specify what data is inserted into the fields you define in the Container.

How aggregation works

Use aggregation to apply commonly used database functions to reduce multiple data items to a single data item.

When you enable aggregation in a Container component, rows are grouped according to the time span you specify in the Aggregate by field in the Aggregation panel. For example, if the time unit is Day, then the timestamps are used to identify which calendar day a row belongs to, and there is one group for each day. If the time unit is Week, there is one group for each week, and so on.

Aggregation functions are performed on all the fields of each row within a time span group. You set the function used on each field in the Aggregation column in the Table definition panel. The Timestamp field is the exception to this in that it is automatically set to the Maximum function and you cannot change it.

For example, suppose you have enabled aggregation and the following functions are applied to the fields.

Table 1. Example container
Field Aggregation
timestamp Maximum
integerField Sum
doubleField Minimum
stringField Last Inserted

This aggregation is the equivalent to applying the following select statement to the example container.


SELECT MAX(timestamp), 
SUM(integerField), 
MIN(doubleField), 
LAST(stringField) 
WHERE timestamp => [beginning of time unit] AND timestamp < [end of time unit]

This select statement is repeated for every group of rows that falls within a time unit. Each statement results in a single row, one per time unit group. These rows are the new contents of the container.

If the example above had used the Group by function for stringField instead of the Last function, the select statement would look like this.


SELECT MAX(timestamp), 
SUM(integerField), 
MIN(doubleField) 
WHERE timestamp => [beginning of time unit] AND timestamp < [end of time unit], 
GROUP BY stringField

This results in a single row for every unique stringField value within a time unit group. With Group by, a time unit group contains multiple rows if there are multiple unique values in the field where the Group by function is applied.

Available aggregation methods

The aggregation methods available for a field depend on the data type. The following table describes all of the aggregation methods.

Table 2. Aggregation methods
Aggregation method Description
Last Inserted Use the most recently inserted value in the field.
Minimum Use the lowest value in the field. In string fields, this returns the string that comes first in an alphabetical sort.
Maximum Use the highest value in the field. In string fields, this returns the string that comes last in an alphabetical sort.
Sum Use the total of the values in a numerical field.
And For Boolean values, use the false value if one is present; if all values are true, use the true value.
Or For Boolean values, use the true value if one is present; if all values are false, use the false value.

Aging

In the Aging panel of the Container component, you can specify how long data is retained. You select the time unit and the number of time units, such as 2 weeks or 1 day. You also specify whether the time span is calculated on a calendar or rolling basis.

Overflow

In the Overflow panel of the Container component, you can set a limit on the number of records, or rows, that the component stores. You can specify whether to delete rows based on the lowest or highest value of any defined field that you specify.

When a maximum number of rows is reached, the overflow settings determine what happens when a request is made to store another row. The options in the If the maximum number of rows is exceeded delete field are as follows.
  • Minimum - deletes the item containing the smallest value in the specified field.
  • Maximum - deletes the item containing the largest value in the specified field.

Detailed Container example

Suppose that your goal is to offer customers a discount for printer paper when they purchase more than $200 in printer paper in a calendar month. You can set up a trigger system as follows.

  • Create a Simple Event component that fires an event when it receives printer paper purchase data.
  • Create a Container component to store dollar amounts of printer paper purchases.
    • In the Aging panel, set a calendar month time span to set a limit on the length of time that the data is retained. The Container is cleared at the end of every month.
  • Create a Container Manipulator, CM1, that listens for the Simple component event.
    • In the Action panel, specify that the purchase amount is inserted into the Container.
  • Create an Action component that listens for the CM1 event.
    • In the Firing Condition panel, define a Boolean expression that applies the Sum function to the dollar amount field in the Container and returns True when the amount is equal to or greater than $200.
    • Optionally, add the same Boolean expression in the Additional Information section of the Outcome panel. This includes the dollar amount in the data that is written to the Outcome table.

Each time a customer purchases printer paper during a calendar month, the dollar amount is saved. If the total amount is equal to or greater than $200 in any month, the Action component fires for that customer.

Tip: This example uses a limited Container that contains only the data needed for the single trigger system described in this scenario.

Diagram of the trigger system described in this section