Answer the question
In order to leave comments, you need to log in
How to store transactions?
Hello. There is an application with a certain currency that the user can spend or receive, the movement of this currency must be taken into account, that is, you need to store a transaction with information about what, from where, where it came from, and there are also some types of transactions that have additional information.
What table structure can be used for such transactions, given that different types of transactions may have different information?
postgres base.
Answer the question
In order to leave comments, you need to log in
columns
what, from where, where did it come from,
usually these are 2 tables: wallets and transfers (1st), in some cases they add a connection between the wallet and the user (m-1), if you have not just a currency but a payment order, add the concept of an account (an offer to pay, by the way, this is the most complex entity , depending on your wishes, it can grow into a megastructure, such as all sorts of escrow or regular auto payments), everything else is encoded in the fields of these tables.
Cryptocurrencies have taken a different path and made it a rule - let everything be a list of transactions, and a transaction is a code - and around this they wrap whatever you want (although sometimes it turns out through the ass, but universally). Those. there is generally only one table - a transaction, everything else is caches (for example, the list of unspent outputs is restored by rescanning the list of transactions)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question