Relationships and Cardinality
Define edges between entities with labels, typed properties, 10 cardinality values, directional control, and FK-generated connections.
Relationships in the data model are edges that connect entity nodes. Each edge defines how two entities relate, with support for labelling, cardinality, directionality, and typed properties. The graph editor renders these edges with cardinality-aware arrow decorations so that structural constraints are visible directly on the canvas.
Edge Structure
Every relationship edge in the model has the following fields.
The 10 Cardinality Values
The model supports 10 cardinality expressions that cover all standard relationship multiplicities. Cardinality is displayed in graph-db authoring mode when the mode configuration has showCardinality enabled.
Cardinality-aware Arrow Rendering
The graph editor renders different visual decorations on edge endpoints based on the cardinality value. This provides immediate visual feedback about the nature of each relationship.
Edge Properties
Relationships support typed properties with the same structure as entity properties (GraphEdgeProperty is an alias for GraphNodeProperty). This is useful for relationships that carry data of their own.
// Example: an ENROLLED_IN relationship with properties
{
id: "edge-uuid",
source: "student-node-id",
target: "course-node-id",
label: "ENROLLED_IN",
cardinality: "N:M",
directed: true,
properties: [
{ name: "enrollmentDate", type: "date", required: true },
{ name: "grade", type: "string", nullable: true },
{ name: "status", type: "enum", enumValues: ["active", "completed", "withdrawn"] }
]
}
FK-generated Edges
Foreign key properties on entities optionally generate visible edges. When an entity property has keyRole: "foreign" and its fkResolution has showEdge: true, the editor creates an edge between the source entity and the resolved target entity.
Directed vs Undirected Edges
Edges default to directed (directed: true), meaning they have a source and a target with an arrowhead indicating direction. Setting directed: false removes the directional arrowhead, representing a bidirectional or symmetric relationship. Cardinality decorations still appear on both ends regardless of directionality.
Composite Constraints
Beyond single-property constraints, the model supports composite constraints that span multiple properties on a node label. These are used for composite indexes and multi-column uniqueness constraints.
interface GraphCompositeConstraint {
id: string; // Unique ID
type: 'index' | 'unique'; // Constraint type
nodeLabel: string; // Which entity label this applies to
propertyNames: string[]; // Ordered list of property names
name?: string; // Optional human-readable name
}