Search code examples
mongodbschemamulti-user

How to create database schema for multiuser application (No SQL)


I am using MongoDB as my application database. The application need to have login for each user and fetch individual user data on successful login.

Now i would like to know what are the possible ways to support multiple user on an application. Will there be any database locking issue, when i store data for all users into a single database table.

I currently have a 'User' table to store the user login information and 'InfoTable' to store information. For each row of 'InfoTable', I have 'userId' also stored along with the information.


Solution

  • As far as I know mongo locks documents. But the whole idea behind having a nosql database is not to create different tables/schema, your application can maintain the relationship etc. User and user info should be in the same collection in my opinion. You can have a user poco class with userinfo as a property. This way you can have all the data about a user in one go. As far as the performance are concern if you have all of your related information you will have less read request and don't have merge data to form a meaningful object.