Quick MongoDB Naming Conventions

I have written this post to serve as some quick guidelines for how databases and collections should be named in MongoDB to keep my projects consistent. Partially derived from this StackOverflow post.

By following the guidelines from the very start of your project, these naming conventions should help you create a scalable and consistent MongoDB database.

  • Database
    • camelCase
    • append DB to the end of name (e.g. myDB, myNewDB)
  • Collections & document fields
    • Lowercase names (collection names in MongoDB are case-sensitive)
    • Plural collections (e.g. users rather than user)
    • No word separators when possible – although I use CamelCase when not possible with perhaps only two separate words max; e.g. firstName, lastName.

Other general rules include:

  • Keep names of databases, collections etc. as short as possible
  • No special characters (unless using an _ underscore as the prefix to an internal MongoDB field e.g. _id)

See also: How to Install MongoDB on MacOS


No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *