Has anyone used a schema design like below to allo...
# orm-help
c
Has anyone used a schema design like below to allow tables to extend from a common Type/Table? For instance Motors, Batteries, and Flight Controllers are all Products. And so they’ll have common fields and table links. But they also have attributes that are unique that sub-product. I think this will solve my problem where can only link between tables by a single Type. For instance
Images
has a
product: FlightControler
attribute. I was trying to figure out how I could link my Images to other product types and really couldn’t figure it out. You can’t do
product: [FlightControllers, Motors, Battery]
, you have to give it a single Type to create a relationship to. So with this model, I think I can link all my other tables with
product:  Product
and then the product can then link to all of the product types. Thoughts?
j
we wanted to do something kind of similar to this, we had a Request type that would extend to have either a registered Location type or custom coordinates, this could be accomplished with GraphQL Interfaces or UnionTypes but Prisma's engine doesn't implement this https://www.prisma.io/docs/datamodel-and-migrations/datamodel-POSTGRES-knum/#more-sdl-features As an alternative, kind of an SQL like structure making a one-to-one relationship between the main Request Type and it's secondary Coordinate | Location Type by first creating the secondary type then getting it's ID and putting that into a intermediary Type that specifies the Request Type with an Enum and then linking that RequestType type to the main Request type. So to get the Request's positional data (Location/Coordinate) you look up it's RequestTypeLink Type then get the Positional Type's ID from the RequestTypeLink and the type of Positional type from the enum on the RequestTypeLink, then you query prisma again for the ID by the type specified from RequestTypeLink enum which will either be Coordinate or Location, kind of like sql.
in your case, you could create a intermediary Type called something like ProductLink with an ID field and an Enum field that specifies the Product Type and then the ID of the actual product which you then query Prisma for after the first query
the ProductLink Type would be a field on the Image type