If I’m understanding right, you want the database to somehow encode the same level of constraints/rules/variants that your domain has. Right? If so, yeah you’re right that no databases have the same level of features to model what you expect to do in ocaml.
I separate my domain logic from my storage code, and have a layer in b/t to convert domain, parsed, validated data into sql and back. At the database level, I’ll do the best I can to design invariants as much as I can but it’s impossible to have it perfect.
sql / external data is parsed → domain
domain → transformed → sql