Streams and relations are key concepts in the Intelligent Event Processor (IEP).
A stream is a series of timestamped events that have the same schema.
Assume that a stream has the following characteristics:
The following table shows an example of the events in the stream during a brief interval of time.
| Symbol | Price | Timestamp |
|---|---|---|
| ADBE | 21.60 | 2008-12-15-T10:30:02:899-05.00 |
| AMZN | 50.12 | 2008-12-15-T10:32:44:674-05.00 |
| ATT | 23.88 | 2008-12-15-T10:35:17:198-05.00 |
| ADBE | 21.70 | 2008-12-15-T10:38:23:257-05.00 |
A relation is a collection of events that match a user-defined condition at a point in time.
You can define the condition in various ways. For example:
Assume that you define the condition as all events that arrived in the last five seconds. For the example in the "Streams" section, the relation at time 2008-12-15-T10:35:00:000-05.00 would consist of the following events.
| Symbol | Price | Timestamp |
|---|---|---|
| ADBE | 21.60 | 2008-12-15-T10:30:02:899-05.00 |
| AMZN | 50.12 | 2008-12-15-T10:32:44:674-05.00 |
Let's move forward one second in time. The relation at time 2008-12-15-T10:36:00:000-05.00 would consist of the following events. Compared with the previous relation, one event has dropped out and one event has been added.
| Symbol | Price | Timestamp |
|---|---|---|
| AMZN | 50.12 | 2008-12-15-T10:32:44:674-05.00 |
| ATT | 23.88 | 2008-12-15-T10:35:17:198-05.00 |
The relation at time 2008-12-15-T10:37:00:000-05.00 would consist of the following events. This relation has the same events as the previous relation.
| Symbol | Price | Timestamp |
|---|---|---|
| AMZN | 50.12 | 2008-12-15-T10:32:44:674-05.00 |
| ATT | 23.88 | 2008-12-15-T10:35:17:198-05.00 |
The relation at time 2008-12-15-T10:38:00:000-05.00 would consist of the following event. Compared with the previous relation, one event has dropped out.
| Symbol | Price | Timestamp |
|---|---|---|
| ATT | 23.88 | 2008-12-15-T10:35:17:198-05.00 |
The relation at time 2008-12-15-T10:39:00:000-05.00 would consist of the following events. Compared with the previous relation, one event has been added.
| Symbol | Price | Timestamp |
|---|---|---|
| ATT | 23.88 | 2008-12-15-T10:35:17:198-05.00 |
| ADBE | 21.70 | 2008-12-15-T10:38:23:257-05.00 |
A relation can be empty. For the example in the "Streams" section, the relation at time 2008-12-15-T10:45:00:000-05.00 would not contain any events because none of the events arrived in the last five seconds.