
Stop a merged customers table from taking the same id, the same email, or the same discount code twice - including global codes that carry no region.
Wire up an order book so lines cannot name a missing order, an order's lines go when the order goes, a product still on an invoice cannot be deleted, a retired category leaves its products behind, and a shipment must name a whole order line rather than half of one.
Give a bookings table named NOT NULL and CHECK rules, including one that judges two date columns together, and roll a rule out over a legacy table that already breaks it.
Build a ticketing schema whose rules the database enforces: primary keys, a unique venue name, a tier code unique per event and channel with nulls not distinct, references that cascade, refuse or clear, a two-column composite reference, named NOT NULL and CHECK rules, and a NOT VALID rule rolled out over a legacy table that already breaks it.