2 Replies
For example, if you use MySQL as db and you have a User and a Post table and inside the User table you define a
type
discriminator column and inside the Post table you define a foreign key of userID referencing the User table and when querying Post table, you add the type
in the where
clause of Post
and add the include
keyword for {user:true} so it returns not only the posts but the user data as well.Prisma
Table inheritance
Learn about the use cases and patterns for table inheritance in Prisma ORM that enable usage of union types or polymorphic structures in your application.