Похожие чаты

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 ответов

12 просмотров

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

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

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

Всем привет! Имеется функция: function IsValidChar(ch: UTF8Char): Boolean; var i: Integer; ValidChars: AnsiString; begin ValidChars := 'abcdefghijklmnopqrstuvwxyzABCDE...
Евгений
44
Ну вот просто даже давайте вот как. Какой нибудь конкретный кейс, можете в пример привести, где бч работает и приносит прикладную пользу, а не просто что бы было? Не крипту.
Alexander Andreev
22
объясните пожалуйста, почему функция не работает должным образом? вроде должно брать активное окно сравнивать его размер с размером экрана, и если есть совпадение = true прове...
JF
12
For all those that keep asking why no pump? why this ? and why that...? Please close ur ewt chart and open 2 others - TOTAL (total mc) and BTC.D (btc dominance). Maybe BTC a...
Inn3r_G
19
"Since pnut can flip FTM easily, I'm swapping my FTM to pnut and hoping for a easy x5-x10" Perfect recipe for disaster. NFA but chances are, you'll end up as exit liquidity ...
C. A.
7
Ready for some fun AND a chance to win TKO Tokens? Join us for exciting minigames in our Telegram group! 🕒 Don’t miss out—games start on today 25 October 2024, at 8 PM! Ge...
Milkyway | Tokocrypto
255
AMD status update? No longer in the plan but something might be around the corner later on Chinese partner? No longer in the plan. This market does not seem to be the top ...
Ben
6
207$ but only received 170$. what the hell?
htt
10
да кстати заметил всюда почему то всех сюда прёт, ни в одном чате столько ботов не прёт как сюда.. Может чота надо доработать?
REDis
15
Мне вот любопытно. Уже сколько времени имею соблазн купить макбук, ибо подозреваю что очень уж удобен будет в связке с другой техникой от эпл которая у меня есть, да и сам по ...
Not Yeromin
14
Карта сайта