Relational database schema from business rules, with indexes and migrations

par fidji ChatGPT Anglais ~695 tokens
Extrait public Verrouillé
You are a database architect. Extract entities and business rules, settle every cardinality, normalise to 3NF, choose keys, CHECK / UNIQUE / FK actions, amounts in minor units, timestamps with time zone, then derive indexes from the top queries…

À propos de ce prompt

Turns a plain-language description of a business into a production-ready relational schema: entities and cardinalities, Mermaid ER diagram, 3NF with justified denormalisation, constraints, money and time-zone pitfalls, indexes derived from your real queries, DDL and a zero-downtime migration plan.

Exemple de résultat

Fourni par l'auteur
STEP 1 — Rules - A time entry belongs to exactly one task and one employee; a task belongs to exactly one project. Question 1: can one time entry be invoiced twice (corrections), or is it locked once invoiced? STEP 2 ```mermaid erDiagram CLIENT ||--o{ PROJECT : owns PROJECT ||--o{ TASK : contains TASK ||--o{ TIME_ENTRY : logs INVOICE ||--o{ TIME_ENTRY : bills ``` STEP 4 — DDL (excerpt, PostgreSQL) ```sql CREATE TABLE time_entry ( id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY, agency_id bigint NOT NULL REFERENCES agency(id), task_id bigint NOT NULL REFERENCES task(id) ON DELETE RESTRICT, employee_id bigint NOT NULL REFERENCES employee(id), work_date date NOT NULL, minutes integer NOT NULL CHECK (minutes BETWEEN 1 AND 1440), rate_cents integer NOT NULL, -- frozen at entry time invoice_id bigint REFERENCES invoice(id) ); ``` STEP 5 — "unbilled hours per client" → CREATE INDEX ON time_entry (agency_id, task_id) WHERE invoice_id IS NULL; (partial index, stays small)…

Fiche technique

Modèle
ChatGPT
Langue du prompt
Anglais
Pour qui
Developers and founders designing the database of a new application or a new feature
Longueur
~695 tokens (estimation)
Format livré
Texte du prompt, affiché en ligne après achat

Avis

Réservés aux acheteurs

Aucun avis pour l'instant. Seuls les acheteurs de ce prompt peuvent en laisser un.

Signaler ce prompt