Data Model for a Legal System
Designs a database schema for legal entities with emphasis on versioning, audit trail, and tenant isolation — three things that are very hard to retrofit.
Prompt
Design a data model for a legal system. Three things are nearly impossible to retrofit: versioning, audit trail, and tenant isolation. Decide them now.
Domain: [describe entities and process] Database: [PostgreSQL / other] Multi-tenant: [yes / no] Retention and regulatory requirements: [if known]
Produce:
- Tables — full DDL with types, NOT NULL, defaults, and foreign keys. Justify every non-obvious type choice.
- Versioning — how document or clause versions are stored. Append-only, history table, or temporal. Justify against the query "what did the text say on date X".
- Audit trail — who did what and when, on which tables, and how audit rows are protected from deletion or modification.
- Tenant isolation — tenant_id column with RLS policies, or separate schemas. Specify the actual policy and how you test that it holds.
- Deletion — soft delete vs hard delete vs regulatory deletion obligation. These conflict; decide explicitly.
- Indexes — for each expected query, the index serving it. State which indexes not to add and why.
- Constraints — every business rule enforceable in the database rather than application code. Prefer a constraint over application validation.
Finally: three decisions that will be expensive to change in a year, and what makes them reversible.
Why this converts well
- Ready to copy and use immediately
- Tailored for legal and public-sector work
- Easy to adapt to internal workflows
Tags
Related Prompts
Tool Specification for a Legal AI Agent
Produces a complete agent tool definition — schema, description, errors, permissions — with emphasis on tools that perform irreversible actions.
Designing a Structured Output Schema for Legal Data
Designs a JSON schema for legal data extraction with explicit representation of uncertainty and missing values instead of silent defaults.
Regression Test Suite for a Production Prompt
Builds a test suite for a prompt before changing it, catching silent regressions introduced by an innocent-looking improvement or a model swap.