Many-to-many relationships
Model relationships that are not simple references: m2m tables, related lists and when to use a relationship record.
Model relationships that are not simple references: m2m tables, related lists and when to use a relationship record.
- m2m definitions generate the join table and both related lists
- One row per pair keeps the model clean and reportable
- Defined relationships handle computed lists a join cannot express
- Relationship queries run on every form load, keep them cheap
Why a reference is not enough
A reference field holds one value. When an incident can affect many CIs and a CI can be affected by many incidents, you need a join table with a reference to each side. The platform calls this a many to many definition and generates the table and related lists for you.
Creating one
Use System Definition, Tables and Classes, Many to Many Definitions. Give it the two tables and labels for each direction. The generated table holds one row per pair, and both sides get a related list.
Relationship records
For lists that cannot be expressed as a simple join, use a defined relationship (sys_relationship) with a query script.
- Relationships can show records from any table using your own query
- They appear as related lists you can add through form design
- Keep the query efficient, it runs every time the form opens
- Prefer m2m tables where the data really is a pair, relationships are for computed lists