In MongoDb - in case i have fields that are not always contain values - which is better practice: keep same fields in all records even if sometimes those fields are empty or not create those field at all?
10x!
The fields will occupy disk space for the key, even if there is no value, so better do not include them; unless you need to find what documents does not contain such field / contain empty field
MongoDB is schemaless and each document in the collection can have different fields, as long as that makes sense for your application.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With