Is this example of nesting generally accepted as good or bad practice (and why)?
A collection called users:
user
basic
name : value
url : value
contact
email
primary : value
secondary : value
address
en-gb
address : value
city : value
state : value
postalcode : value
country : value
es
address : value
city : value
state : value
postalcode : value
country : value
Edit: From the answers in this post I've updated the schema applying the following rules (the data is slightly different from above):
- Nest, but only one level deep
- Remove unneccesary keys
Make use of arrays to make objects more flexible
{ "_id": ObjectId("4d67965255541fa164000001"), "name": { "0": { "name": "Joe Bloggs", "il8n": "en" } }, "type": "musician", "url": { "0": { "name": "joebloggs", "il8n": "en" } }, "tags": { "0": { "name": "guitar", "points": 3, "il8n": "en" } }, "email": { "0": { "address": "joe.bloggs@example.com", "name": "default", "primary": 1, "il8n": "en" } }, "updates": { "0": { "type": "news", "il8n": "en" } }, "address": { "0": { "address": "1 Some street", "city": "Somecity", "state": "Somestate", "postalcode": "SOM STR", "country": "UK", "lat": 49.4257641, "lng": -0.0698241, "primary": 1, "il8n": "en" } }, "phone": { "0": { "number": "+44 (0)123 4567 890", "name": "Home", "primary": 1, "il8n": "en" }, "1": { "number": "+44 (0)098 7654 321", "name": "Mobile", "il8n": "en" } } }
Thanks!