Hey everyone. I have a general data question, and am wondering how best to handle it with Prisma.
The use case is centered around sharing. The entities are:
• A target asset to be shared
• The entity which shares the asset
• The entity to which the asset is shared.
The target asset could be anything - an image, an office doc, an HTML template (text).
The entity which shares the asset is going to be a User or a Group.
And the entity to which the asset is shared is also a User or a Group.
Each target asset exists in a different DB table, and should be referenced in this Sharing table. For instance, imagine the use case:
A User shares an Image with a Group. The image is stored in the Images table, with a UUID ID, and the User and Group are in their respective tables with UUID IDs.
If you're still with me, here's where Prisma comes in.
I want to create a table called "Shares", and the list of columns I intend to use is:
• targetAssetType: string
• targetAssetId: UUID (* but could belong to a number of tables - so not a proper FK)
• fromEntityType: string
• fromEntityId: UUID (same as above)
• toEntityType: string
• toEntityId: UUID (same as above)
As mentioned, the id fields aren't proper foreign keys. I guess there's nothing wrong with just storing UUIDs in them as plain strings and then referencing the related entity by the associated *Type attribute. But I just wonder if Prisma has something slick - or if my plan won't work for some reason.
Thanks for any help/feedback/suggestions.