Похожие чаты

Hello, I'M struggling to design my database. There are many types

of financial transactions and each is stored in its own table. When it comes to calculating user's balance I realized it was a big mess as I needed to select many different non consistent rows from multiple tables and add them all up. So I thought what if I create a single table that would summarize the transaction (for example amount and user id who owns it) and reference a more detailed record and have a field to specify what kind of transaction it is. As it turned out: the thing that I was trying to implement is called 'polymorphic associations' and there's no way to implement it with mySQL in a reliable way. There are some workarounds but none of them guarantee the data integrity on the level I want it to be. At the end I got so desperate that I started looking at other DBMSs but none of them seem to fit my case as well.

Do you have any recommendations? Perhaps, should I not be afraid of writing large and growing functions for calculating users' balances? Or should I go with the best option of modelling polymorphic associations in MySQL and leave a slight risk of data inconsistency? Or maybe there are DBSMs that can solve my problem without workarounds?

3 ответов

13 просмотров

postgreSQL?

What's the inconsistency problem that you're running into?

Polymorphism in RDBMS is mostly unimplemented in most major databases as I think it is currently not supported by the SQL language. This is the kind of thing that may either require either a good amount of voluntary bad design, a document based database with correct acid semantics or a domain specific DBMS

Похожие вопросы

Обсуждают сегодня

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта