database
via PatrickJS/awesome-cursorrules
Database best practices for Prisma and Supabase integration
What is database?
Guidance on database design, security, and optimization for Prisma ORM and Supabase backends. Covers schema design, migrations, query optimization, RLS policies, and performance monitoring across both platforms.
- Schema design with proper model naming, relations, field types, indexes, and constraints
- Migration management and seeding strategies for Prisma
- Query optimization including filtering, relation loading, pagination, and N+1 prevention
- Supabase RLS policies and authentication configuration
- Connection pooling, caching, and batching for performance
- Encryption, backups, and sensitive data handling for security
Applies to
File patterns this rule matches.
Rule definition (reference)
Source of truth, from the repository.
Database Best Practices
Prisma Setup
- Use proper schema design
- Implement proper migrations
- Use proper relation definitions
- Configure proper connection
- Implement proper seeding
- Use proper client setup
Prisma Models
- Use proper model naming
- Implement proper relations
- Use proper field types
- Define proper indexes
- Implement proper constraints
- Use proper enums
Prisma Queries
- Use proper query optimization
- Implement proper filtering
- Use proper relations loading
- Handle transactions properly
- Implement proper pagination
- Use proper aggregations
Supabase Setup
- Configure proper project setup
- Implement proper authentication
- Use proper database setup
- Configure proper storage
- Implement proper policies
- Use proper client setup
Supabase Security
- Implement proper RLS policies
- Use proper authentication
- Configure proper permissions
- Handle sensitive data properly
- Implement proper backups
- Use proper encryption
Supabase Queries
- Use proper query optimization
- Implement proper filtering
- Use proper joins
- Handle real-time properly
- Implement proper pagination
- Use proper functions
Database Design
- Use proper normalization
- Implement proper indexing
- Use proper constraints
- Define proper relations
- Implement proper cascades
- Use proper data types
Performance
- Use proper connection pooling
- Implement proper caching
- Use proper query optimization
- Handle N+1 queries properly
- Implement proper batching
- Monitor performance metrics
Security
- Use proper authentication
- Implement proper authorization
- Handle sensitive data properly
- Use proper encryption
- Implement proper backups
- Monitor security issues
Best Practices
- Follow database conventions
- Use proper migrations
- Implement proper versioning
- Handle errors properly
- Document schema properly
- Monitor database health
Related rules
Deno automation scripts and workflows for @findhow package ecosystem

Production-ready Docker with pinned versions, multi-stage builds, non-root users, and security scanning.
Expert guidance for DragonRuby game development with Ruby best practices.
Expert guidance for Drupal 11 development with PHP 8.x and Symfony 6 best practices.
Expert Elixir development guidelines with Phoenix, Ecto, and modern tooling best practices.
Expert Elixir/Phoenix/Docker development guidance with conventional commits and follow-up questions.