Good way to do many to many relationship Prisma

I have these schemas where I want to create a many to many relationship between the Xyz table to the subcategory as well as between the Kva table to the subcategory. This is a schema sketch of how I would want to do it but I get the error: Error validating: Embedded many-to-many relations are not supported on MySQL. Please use the syntax defined in https://pris.ly/d/relational-database-many-to-many

Is there any way to do it without intermediate tables? Will add up to a lot of tables over time 🙂

model Subcategory {
id String @id @default(cuid())
name String
xyzs Xyz[] @relation("XyzSubcategory")
kvas Kva[] @relation("KvaSubcategory")
}

model Xyz {
id String @id @default(cuid())
questionPrompt String @db.Text
...
subcategories Subcategory[] @relation("XyzSubcategory", references: [id], fields: [subcategoryId])
subcategoryId String?
}

model Kva {
id String @id @default(cuid())
questionPrompt String @db.Text
...
subcategories Subcategory[] @relation("KvaSubcategory", references: [id], fields: [subcategoryId])
subcategoryId String?
}
Prisma
How to define and work with many-to-many relations in Prisma.
Was this page helpful?