Constraints
To keep integrity within typically an event source when appending events to an event sequence, you can leverage constraints. Constraints are rules that run on a database level within Chronicle, allowing or not allowing an event to be appended. This is one of the main ways Chronicle enforces the Dynamic Consistency Boundary by validating that the decision remains correct at append time.
Unique Constraint
Section titled “Unique Constraint”A unique constraint specifies events that work on a specific value you want to keep unique within an event source. For instance, let’s say you’re creating a system for registering users, the username is typically something you want to keep a unique constraint on. Any events that either create the user or modify the user name in any way would typically then be included in the constraint definition.
Unique Event Type Constraint
Section titled “Unique Event Type Constraint”The unique event type constraint lets you constrain on a specific event type being unique per event source. If any attempt is made to append the same event type twice for an event source, it will be a constraint violation.