diff --git a/reference/database/schema.md b/reference/database/schema.md index 7ebaa1ea..891d05f7 100644 --- a/reference/database/schema.md +++ b/reference/database/schema.md @@ -397,14 +397,14 @@ type Network @table @export { ### `@relationship(from: attribute, to: attribute)` — foreign key to foreign key -Both `from` and `to` can be specified together to define a relationship where neither side uses the primary key — a foreign key to foreign key join. This is useful for many-to-many relationships that join on non-primary-key attributes. +Both `from` and `to` can be specified together to define a relationship where neither side uses the primary key — a foreign key to foreign key join. Cardinality is determined by the target (`to`) attribute: a scalar `to` attribute gives a many-to-one join (as below), while an array `to` attribute gives a many-to-many join. ```graphql type OrderItem @table @export { id: Long @primaryKey orderId: Long @indexed productSku: Long @indexed - product: Product @relationship(from: productSku, to: sku) # join on sku, not primary key + product: Product @relationship(from: productSku, to: sku) # many-to-one join on sku, not primary key } type Product @table @export {