Prisma Relations & Associations in Prisma

From the Prisma ORM cheat sheet · Prisma Schema & Models · verified Jul 2026

Prisma Relations & Associations

Define relationships between models including one-to-one, one-to-many, and many-to-many

typescript
// One-to-One
model User {
  id      Int     @id @default(autoincrement())
  profile Profile?
}

model Profile {
  id     Int  @id @default(autoincrement())
  userId Int  @unique
  user   User @relation(fields: [userId], references: [id])
}

// One-to-Many
model User {
  id    Int    @id @default(autoincrement())
  posts Post[]
}

model Post {
  id       Int  @id @default(autoincrement())
  authorId Int
  author   User @relation(fields: [authorId], references: [id])
}
💡 Relations are defined on both sides of the relationship
⚠️ Use @relation to disambiguate multiple relations
📌 Cascade deletes with onDelete: Cascade
✅ Self-relations require explicit relation names

Continue with Prisma ORM

Save the full cheat sheet or work through every related task.

More Prisma tasks

Back to the full Prisma ORM cheat sheet