MongoDB + web application: a database for each user

I am in the process of evaluating MongoDB for a personal project. I am building a site that will allow users to register and store information on my server.

When evaluating MongoDB, I saw that it can create a database on the fly, the first time a record is entered. This made me think that I could split the data for each user into my own database. The database name will be inferred from the unique user ID. After user registration during the first storage of information, their database will be created.

Does anyone know if this is a possible project with MongoDB? Would it be better to just store all user data in one database?

+6
source share
1 answer

Yes, one collection is better, so you can take advantage of indexing.

Iterating over a list of databases or collections will always take O (N) time, while you can reach O (log N) time to find individual documents using indexes.

+4
source

Source: https://habr.com/ru/post/904198/


All Articles