I am making a budget management app which allows users to enter entries of their expenditures with the following schema:
user_id, date, item, currency, amount_of_money, category
When the app first loads, the app will only need to load the specific user’s expenditure in the previous month.
So the question comes:
Should I put all users info in one single table, or each user has an individual table, or are there better alternatives? If I put everything in one table, the app has to go through all irrelevant users info to extract the info of one user and it seems inefficient, but I also saw online making a table per user is a terrible idea too
Assume the data is appended chronologically to the table, with the first entry being the earliest date. Since we only need the last month data, there’s no need to query from the first data, but just from the bottom most till the date has passed a month ago, and stop reading the data above (as we know it’s definitely irrelevant), then just directly end the search and return the data. In SQL there is a
SELECT … WHERE
- but will it keep checking the top data which we know for sure they are useless? If it will, is there better methods?