I am developing an app that will offer the possibility to filter the users you search (gender, age, location, ...). I want to make this fast and as cheaper as possible, so I have decided to store my data as a n-ary tree, just something like this:
----- Users -----
Root Node: Gender (male or female)
-male
--country (nodes: USA, UK, Spain, Germany, France, Italy, ...)
---age (nodes: 18, 19, 20, 21, 22, ..., 60)
->user (leaf nodes)
-female
--country (nodes: USA, UK, Spain, Germany, France, Italy, ...)
---age (nodes: 18, 19, 20, 21, 22, ..., 60)
->user (leaf nodes)
I think that structuring the database like this will reduce the amount of data, as I don't have to store the gender, country, and age as field in the last documents... But I don't know if this is a bad practices in the NoSql world, or if this will negativily affect the performance (velocity).
Any ideas about if this is a good structure? Or should I store all this properties in every user document and use the "where" query clausure? Thank you.