I've been trying to model an efficient schema for a bill split app, the requirements are as follows:

  1. There can be groups in which there can be multiple participants, and conversations consisting of exactly 2 participants.
  2. One group/conversation can have many bills
  3. One bill can be paid by many people, can be paid for many people (eg. A and B contributed 100$ and it was split equally between A, B, C, and D).
  4. If a user goes into the profile of another user, they can see what they owe to them or vice versa, on a global level, i.e. total of all the groups.
  5. If they go in the group details, they can see individual group members and what they owe to the user or what the user owes to them on the group level.
  6. A bill can have transactions representing payments made for the bill, and the actual amount used by each participant.
  7. These payments can be settled.

It would be great if anyone could guide me on how to model this database efficiently. Thanks!

PS: I'm using MongoDB right now

  • 2
    You already have your verb phrasing on the right path (except for 4, 7). Items 5 and 6 deal with presentation of the data, you can worry about that later. If you want to start there and come back with a outline of what you think the data model should be, that may be a better starting point than basically asking for free consulting. Is this a hobby project? I wouldn't use Mongo for anything involving money. That's not true, I wouldn't use it for anything. – bbaird Aug 4 '20 at 13:43
  • Thanks @bbaird , I have added some more information, changed 1st and 2nd points, and removed the 4th point. Currently using mongo is compulsorily required :/ – Priyadarshan Vijay Aug 4 '20 at 15:50
  • Oof. Well, strap in. Can't offer much help for trying to make this work in a document store but hopefully someone else can assist. – bbaird Aug 4 '20 at 15:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.