A model with multiple tenents and nosql?

When using multi-tenant applications using RDMBS, I use the tenantId columns in each table to indicate which tenant the row belongs to.

How do I do this in a DocumentDatabase? For example, take Mongodb. DBRef path? Or am I stuck in relational thinking? Or are you using something other than documentdb?

(I'm new to nosql)

+4
source share
1 answer

If you have a need for Multitenancy in MongoDB, you can use a different collection for each tenant. If the data is shared between all tenants, I would instead save a list of tenants for each record:

 doc: { _id: doc1 ... // your objects here tenants: [ tenant1, tenant2, tenant17 ] } 

Then, when I search or want to browse the database, you should ask the appropriate tenant:

 db.mycoll.find({ someField : someValue, tenants : tenant2 }); 
+4
source

All Articles