in the database there are tables of clients, transactions и costs . If you have already noticed that the clients table stores information about clients including the balance, the transactions table stores information about cash receipts for each client. And in the table of costs , expenses of each client are usually recorded. Each table is interconnected with a client_id that contains a unique key for each client. Need advice about the logic of obtaining a user's balance each time you log on to the system for example. How would you get a user balance in this situation database? or need to add some other intermediate table? Share your thoughts, friends. What is what and how to take away to get the client's balance. Thanks in advance
- you have a balance already in the clients table, what logic are you trying to think of? - Evgeny Nikolaev
- " If you have already noticed, then the clients table stores information about clients including the balance sheet " No, we did not notice, you did not bring the structure of the tables. If the database is fully normalized, then there can be no balance in the clients table. If it is denormalized, apparently for speed purposes, then the balance in the clients is still there, as you wrote. There, of course, it is automatically conducted using triggers on two other tables. And then the answer to your question "take the balance from the clients and show." - Mike
|