#322 Calculating User Income and Expenses
A user wants to query how much money they have spent. They also want to query how much money they have received. It should also be possible to track this by date. How can this work efficiently in a large database with millions of queries?
CREATE TABLE cash.cash_history (
id uuid NOT NULL,
user_id uuid NULL,
operation_id uuid NULL,
server_time timestamptz NULL,
sum int8 NULL,
CONSTRAINT cash_history_pk PRIMARY KEY (id),
CONSTRAINT cash_history_un UNIQUE (operation_id)
)
Question review
Sign in to start the dialogue
The mentor keeps the context of the current question and your previous messages.
Sign in
Available with Premium
This is just one of the solutions available with Premium. And more:
- 250+ advanced lectures
- 1300+ practice exercises
- 500+ solutions to problems from real interviews
- Personalized Java Hub certificates
- Expanded access to the AI mentor