erd – Accounting database model


Need to build a service with an internal wallet function.
Here is a simple use-case diagram:
Wallet use-case diagram

I have made a DB model
ER-diagram

But I don’t like it for the next reasons

  • No guarantee there will be only 1 sub-type record.
  • No guarantee there will be at least 1 sub-type record.
  • No clear way to display the detailed historical list of entries.

So, the question is – how to organize the DB model right? I am ready to accept even the most radical solutions, like anchor modeling or something. Just want to know the ideal accounting DB model. My favorite DB is PostgreSQL, but in general, it doesn’t matter.