Is there a set of preferred naming conventions for MongoDB entitites such as databases, collections, field names?
I was thinking along these lines:
- Databases: consist of the purpose (word in singular) and end with “db” – all lower case: imagedb, resumedb, memberdb, etc.
- Collections: plural in lower case: images, resumes,
- Document fields: lowerCamelCase, e.g. memberFirstName, fileName, etc
Keep’em short: Optimizing Storage of Small Objects, SERVER-863. Silly but true.
I guess pretty much the same rules that apply to relation databases should apply here. And after so many decades there is still no agreement whether RDBMS tables should be named singular or plural…
MongoDB speaks JavaScript, so utilize JS naming conventions of camelCase.
MongoDB official documentation mentions you may use underscores, also built-in identifier is named
_id(but this may be be to indicate that_idis intended to be private, internal, never displayed or edited.