I have 3 main types: Company, Service, and Specialty. Every Company has a list of Service. Every Service have a list of Specialty. Every Specialty have a list of Specialty (sub-specialties).
Company 1
- Service 1
-- Specialty 1
--- Sub-specialty 1
So I am working on this datamodel on Prisma 1.34:
type Company {
id: ID! @id
name: String! @unique
services: [Service]
}
type Service {
id: ID! @id
name: String! @unique
companies: [Company]! @relation(link: TABLE)
specialties: [Specialty]
}
type Specialty {
id: ID! @id
name: String! @unique
companies: [Company]! @relation(link: TABLE)
services: [Service] @relation(link: TABLE)
sub_specialties: [Specialty] @relation(link: TABLE)
}
My problem is, when I add one Company and use the same Service for that Company in another Company, all other Specialty and Sub-specialty records are coming along with that Service. I want to make Specialty and Sub-specialty fields unique for every company but they also should be under related Service under every company.
I have been working on it for the past 3 days, I would appreciate any help.