#Schema design support for id-type based relations

1 messages · Page 1 of 1 (latest)

lunar sorrel
#

Example schema is like below

modal Person{
  id           Int        @id @default(autoincrement())
  parent_id    Int
  person_type  PersonType @default(contact)
  fullname     String   @db.VarChar(255)

}

modal PersonAssociation{
  person_id           Int
  association_id      Int
  association_type    AssociationType @default(owner)
}

type PersonType { user, staff, contact, client, company, team, project }
type AssociationType { owner, member, manager, viewer, reviewer, share }

#

Assuming above, I want to create Relation Definition in Prisma between Person and PersonAssociation based on AssociationTypes

  • User is a staff
  • Staff has multiple contacts
  • Staff manages multiple client
  • Staff is a member to multiple teams
  • Staff is viewer to multiple project
  • Staff is reviewer in multiple teams
  • Staff has multiple shared contacts
  • Client has multiple projects
  • Client has multiple teams
  • Project has multiple staff
  • Team has multiple project
#

Is t possible or I need to split person types into each schema model?