database-modeling

Design and validate Prisma and PostgreSQL schemas with constraints, soft deletes, and indexes.

Updated Feb 16, 2026
One-click install
npx skills add https://github.com/Fivents/one-id --skill database-modeling
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: database-modeling
Source: https://github.com/Fivents/one-id/tree/main/.claude/skills/database-modeling
Command: npx skills add https://github.com/Fivents/one-id --skill database-modeling

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Provides guidance and validation rules to design Prisma and PostgreSQL schemas that maintain relational integrity, prevent duplicate or inconsistent records, and improve query performance in production systems.

Core Features & Use Cases

  • Constraint Enforcement: Define and validate unique constraints, composite keys, and foreign keys to prevent inconsistent data (e.g., unique(email, organizationId) on Person and unique(personId, eventId) on EventParticipant).
  • Soft Delete Conventions: Standardize deletedAt handling across models and highlight anti-patterns such as ignoring soft delete in queries.
  • Indexing & Performance: Recommend indexes for frequently queried fields and patterns to avoid full-table scans.
  • Use Case: Review and harden the schema for an event-management backend to ensure participant lookups and multi-tenant person records remain correct and performant.

Quick Start

Validate the Prisma schema to enforce composite unique keys for person and event participant, add soft-delete handling, and create indexes for common query fields.

Frequently Asked Questions about database-modeling

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I enforce composite unique keys in a Prisma schema for multi-tenant data?

Enforce composite unique keys in a Prisma schema by applying constraints like unique(email, organizationId) on Person to prevent duplicate records and maintain relational integrity across multi-tenant data.

What is the best way to handle soft deletes in PostgreSQL without breaking query integrity?

Handle soft deletes in PostgreSQL by standardizing deletedAt fields across models and consistently filtering them in queries to prevent soft-deleted records from polluting active data results.

How do I add indexes to Prisma schema fields to avoid full-table scans?

Add indexes to Prisma schema fields frequently used in lookup queries, such as personId and eventId, to optimize query performance and avoid full-table scans in production databases.

Does this schema validation approach work for multi-tenant event management backends?

Yes, this schema validation approach works for multi-tenant event management backends by validating foreign key constraints and composite keys on models like EventParticipant to ensure correct relationships.

Why does my Prisma schema allow duplicate EventParticipant records for the same person and event?

Your Prisma schema allows duplicate EventParticipant records because it lacks a composite unique key constraint like unique(personId, eventId) to enforce one participant per event.