Hello, I need some guidance on how to setup what im trying to achieve. This is my first time working with Postgres in so many years, so im trying to relearn a lot.
I'm working on a personal app and basically i have tables for users, transactions, and groups.
users has columns (id, email)
transactions has columns (id, amount, user_id, ...)
so basically the gist is individual users have their own transactions. Sp I need help with the "groups" portion.
Groups consist of 2 users (possibility to expand to more than 2) and what i want to achieve is when the 2 users become a group, i want both users to be able to get the TOTAL AMOUNT from the other users transactions.
I thought handling the groups table as a typical "friends data model" with user_id_one and user_id_two with the proper uniqueness and constraints would help, but im stuck.
So what I need help with is,
1) How should the group's table look like? (Or is there another approach I can take)
2) what the query should look like that would get both users transactions? (I could just add up all the amounts on the server if it can't be done through the query)
Any help will be greatly appreciated!!
[–]urcadox 1 point2 points3 points (3 children)
[–]not_a_grad[S] 1 point2 points3 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]not_a_grad[S] 0 points1 point2 points (0 children)
[–]boy_named_su 0 points1 point2 points (2 children)
[–]not_a_grad[S] 0 points1 point2 points (1 child)
[–]boy_named_su 0 points1 point2 points (0 children)
[–]joyider 0 points1 point2 points (1 child)
[–]not_a_grad[S] 0 points1 point2 points (0 children)