Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Prisma · Const

model

A Prisma model defines an application-domain entity in the Prisma schema. Prisma maps it to a table for relational databases or a collection for MongoDB.

How it works

A model block declares an application entity in Prisma Schema Language. Its fields describe the model's data and relations, while Prisma maps the model to a database table for relational connectors or a collection for MongoDB.

Syntax

model ModelName {
  fieldName FieldType
}

Key points

  • Models are part of the Prisma schema's data-model definition and describe the application's domain entities.
  • Use a model to represent a distinct entity in the application's domain.
  • With relational connectors such as PostgreSQL and MySQL, each model corresponds to a database table.
  • With MongoDB, Prisma maps a model to a collection instead of a relational table.
  • The declaration syntax is a model block whose contents are fields.

Common mistakes

  • The generated database structure depends on the connector: relational databases use tables, whereas MongoDB uses collections.
  • A model must be expressed as a model block, with its fields declared inside the block.

Example: Define a Prisma model

model User {
  id    Int    @id @default(autoincrement())
  email String @unique
}

Add a model block to schema.prisma, then run Prisma's normal schema-generation workflow to expose the model through Prisma Client.

When to use it

Define application entities

Represent a domain entity such as a user, order, or product in the Prisma schema.

Model data shape and relations

Describe the fields belonging to an entity and its relationships to other entities.

Map entities to database structures

Generate a database representation from a schema model for a relational or MongoDB data source.

Interview questions

QWhat is a Prisma model, and what does it represent?

A Prisma model is a schema-level declaration of an application entity. It maps to a table in relational databases and to a collection in MongoDB.

Follow-up: How are model properties described? Fields inside the model block define the model's data and relations.

QHow do you declare a model?

Models are written as model blocks in Prisma Schema Language. The block contains fields that describe the entity and its relationships.

Follow-up: Where is this declaration normally placed? It belongs in the Prisma schema, typically a file named schema.prisma.

QHow does Prisma map models to databases?

A model represents an entity in the application domain and maps that entity to an underlying database structure. The concrete structure varies by data source.

Follow-up: What changes between relational databases and MongoDB? The model targets a table for relational databases and a collection for MongoDB.

  • Prisma schema
  • Prisma Schema Language (PSL)
  • fields
  • relations
  • scalar types
  • enums

Source: Models (Prisma ORM v6). Checked 2026-10-16.