Books: an immutable double-entry accounting database service
This looks good but some of the background has the air of the kind of artificial problems presented in late night infomercials:<p>> It’s impossible to split a single payment into multiple payouts, since there is a many-to-one relationship of payments to payouts.<p>So your model used a many-to-one relationship when you really wanted a many-to-many?<p>> Since this is just a SQL database, there’s nothing preventing the payouts from becoming inconsistent.<p>Preventing inconsistencies by enforcing constraints is a key point of an RDBMS. This is literally why people use SQL DBs.<p>> The payout_id can be ensured to be a valid foreign key, but nothing is stopping it from being nulled out.<p>You mean, like a NOT NULL constraint? Or, if you mean <i>zeroed</i> out, an appropriate constraint and/or before update trigger protecting the amount?