I am thinking about using snake_case in my mongoDB-documents due to convention in the project. As I researched here, camelCase seems to be a standard in mongodb due to its BSON-storage.
My documents are for example
{
"created_at": "",
"issuer": "my-user-name",
"document_id": "81234-guid",
"file_id": "81234-another-guid",
"details": {
...
}
}
As you see, I under snake_case. That means that many of my field names are one char longer.
- How does this affect the storage?
- Is there any compression or algorithm, that stores field names separatly or is really each field name stored within the BSON?
In my use case the collection there will have many small entries For each document there will be about 10 entities stored in mongodb. There will be about 1.000.000.000 documents, meaning at least 10.000.000.000 entities stored in collection.
The database does not prescribe how to name fields (other than there must be a field named
_id
).In Ruby for example the convention is to use underscore style as you are contemplating.
If you want to use short field names for storage optimization, changing from camel case to underscore will be much less of a difference than actually using shorter field names (for example
n
instead ofcount
, etc.).