Choosing the right database patterns can make or break your application at scale. This article covers proven patterns for designing databases that grow with your user base.
// Prisma schema with advanced patterns
// schema.prisma
model User {
id String @id @default(cuid())
email String @unique
name String
posts Post[]
profile Profile?
createdAt DateTime @default(now())
@@index([email])
@@index([createdAt])
}
model Post {
id String @id @default(cuid())
title String
content String @db.Text
published Boolean @default(false)
author User @relation(fields: [authorId], references: [id])
authorId String
tags Tag[]
viewCount Int @default(0)
createdAt DateTime @default(now())
@@index([authorId, published])
@@index([createdAt(sort: Desc)])
@@fulltext([title, content])
}



