<@U04UQ68083H> is there a way in keto to limit a r...
# ory-copilot
b
@chilly-king-10285 is there a way in keto to limit a relation,, for example a
User
can only have a single
ownership
relation of a
Organisation
c
A message from kapa.ai
New message text here
b
@chilly-king-10285 i take it that's the same for Many-to-1 relationships too?
c
A message from kapa.ai
Yes, that's correct. Ory Keto inherently supports many-to-many relationships, but you can implement many-to-one or one-to-one relationships at the application level. In a many-to-one relationship, many
User
objects could have a relationship to one
Organisation
object. This is naturally supported in Keto as you can add the same
Organisation
relation to many
User
objects. However, if you want to ensure that an
Organisation
can only have a relationship with one
User
(i.e., one-to-many from the
Organisation's
perspective), you would need to enforce this at the application level. This means that when you add a new
User
relation to an
Organisation
, you would first check if a
User
relation already exists for that
Organisation
. If it does, you could choose to not add the new relation, or remove the existing relation before adding the new one. Here are the relevant knowledge sources: - [Define relationships in the OPL](https://www.ory.sh/docs/keto/modeling/create-permission-model#define-relationships-in-the-opl) - [Relation declaration](https://www.ory.sh/docs/keto/reference/ory-permission-language#relation-declaration)