Relationships between Tables

Learn about SQL table relationships and how they can be implemented with the Prisma ORM.

One core aspect of SQL is the relationships between tables—that is, how different tables relate to each other. There are four relationships in SQL:

  • One-to-one
  • One-to-many
  • Many-to-one
  • Many-to-many


A one-to-one relationship occurs when an entity is mapped to another entity uniquely, like when a record in a table maps to only one record in another table. A good example is a relationship between humans and their fingerprints.

In Prisma, we can achieve this with the @relation annotation. First, in the schema.prisma file, we define the model for fingerprints and humans as shown below. The model should include their unique IDs and other relevant information.

Get hands-on with 1200+ tech skills courses.