Document Database like MongoDB Design of an expense tracker application

467 views Asked by At

Getting started in a design of an application that tracks expenses. Using MongoDB only to get familiar with document oriented DBs.

If I start with a doc design that has one doc per day, and that doc has info like where each dollar was spent, and the amount, am I necessarily starting off in the wrong direction?

I eventually want to slice and dice all of the data like how much was spent at Target between two dates, how much was spent in restaurants for a month, stuff like that.

My question is if I start by having a design that is day oriented, will I get into any trouble right away?

1

There are 1 answers

0
ryan1234 On

I think that would be just fine. You can make the _id anything you want, but consider making it milliseconds since the Epoch. That might make range queries easier to work with. You can also embed the string version of the date in each document so you don't always have to parse the _id field.

I don't think you'll get into trouble with that design, but prepare to learn a lot when it comes to writing queries in Mongo. Try to stay within their recommendations for writing queries or things can get very slow.