Set filters
Set filters compare two groups of rows collected during a relational classification.
Instead of checking rows one by one, a set filter compares two sets of related rows and decides which rows should remain in the evaluation.
They are useful when a rule depends on how two collections of rows relate to each other.
When set filters are useful
Set filters are used when the rule depends on comparing groups of rows.
Examples:
- Do two related entities share at least one common item?
- Are all rows in one set also present in another set?
- Should rows that appear in another collection be removed?
- Do two sets contain different elements?
If the condition can be checked row by row, a classification filter is usually the better choice.
Set filters are used only when the comparison must be done between sets of rows.
How set filters work
During relational classification evaluation, the system may produce several result sets at different steps in the relation path.
A set filter compares:
- Set A – a set produced at an earlier step
- Set B – the set produced at the current step
The filter applies a set operation to determine which rows remain.
Example:
Tables
- Customer
- Booking
- Event
Relations
A set filter could compare:
This would keep only events that appear in both sets.
Supported operations
Set filters support several standard set operations.
Intersection
Keeps rows that appear in both sets.
Union
Combines rows from both sets.
Difference
Keeps rows in A that do not appear in B.
Reverse difference
Keeps rows in B that do not appear in A.
Symmetric difference
Keeps rows that appear in only one of the sets.
Example
Tables
- Student
- Course
- Enrollment
Relations
Set filter:
Result:
| Student | Courses enrolled | Allowed courses | Courses counted |
|---|---|---|---|
| Anna | Math, Physics | Math | Math |
| Erik | Biology | Math | (none) |
Only the courses present in both sets are kept.
Important constraint
Both sets being compared must contain rows from the same table.
This ensures the system can compare row identities correctly.
However, the comparison is not completely free.
A set can only be compared against the first earlier step in the relation path that produces rows of the same table type.
You cannot choose any earlier set of the same type.
Example relation path result sets:
At Step 4, the comparison can only use the Course set from Step 3, because it is the closest earlier step with the same table type.
For example:
is valid, but
is not allowed.
A simple way to think about set filters
Set filters answer a question like:
How do these two groups of related rows compare?
By comparing sets instead of individual rows, relational classifications can express more complex structural rules.
Related resources
Reference
Related concepts