Blueluelueluelue
PPrisma
•Created by Blueluelueluelue on 1/3/2025 in #help-and-questions
Join a column with multiple tables.
I want to store all media in the system in a central table. Now the associated resource of the media can be anything, like chat, project, ticket, etc.
So I have a Media model like this
and an arbitrary number of resource models
It compiles just fine but during insertion it fails because a foreign key constraint get violated. When I try to insert a media associated with ResourceA, the ResouceB foreign key constraint gets violated.
I know a simple solution would be have a column for each resource table like resourceAId, resourceBId and so on but is there a more elegant way?
2 replies