[email protected]
1 month ago

Relationships with a "type" of relationship

Posted 1 month ago by [email protected]

I need to create relationships between objects, but with an associated named type - effectively an ontology. And I'm wondering if there is any native way to do this, other than just creating multiple tables (which can certainly be done).

Example:

  • Item A --- has ---> Item B
  • Item A --- uses ---> Item C
  • Item A --- uses ---> Item D
  • Item A --- uses ---> Item E
  • Item A --- uses ---> Item F
  • Item A --- hasSameWidgetAs ---> Item D

(note: The inverse relationships are Many to Many in most cases, too)

The number of relationship types isn't too crazy - probably about 5 or 6 for now - but I'm wondering if there's a way to specify a named relationship on belongsTo(), hasOne(), hasMany(), etc...

Please sign in or create an account to participate in this conversation.