# Accounting database model

database-designerd

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

I have made a DB model

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.

Here is my accounting_entry main entity implementation – https://gist.github.com/dilame/dcb55112833d0ad6579a08fd573592da

All the other entities supposed to be sub-type of accounting_entry as shown in the ER diagram.