SQL schema vs NoSQL namespace

Viewed 206

I am pretty new to NoSQL and would like to fully understand the concept of namespace and how it compares to SQL schema. I have seen plenty of useful analogies between tables, row, ... and their NoSQL counterparts.

Could you please help me understand the namespaces ?

In particular, I would like to know how I could leverage them to segregate the data of my dozen of customers ? I want to prevent accidental information leak between two of then, while still using a single database.

1 Answers

It really depends of the database engine you are using, it is hard to give a generic answer.

Ideally, if you really want to segregate the data, you can use multiple databases (in Redis, Redis Enterprise, MongoDB). In this case you are sure that data are separated. But you say you want to use a single DB. (why?)

If you want to stick with a single database you have various options, once again depending of the database engine you are using.

If you are using Redis:

  • you can use specific namespace based on key pattern, for example app:cust-001:orders, and you control the access to the data based on the key name/pattern. In Redis 6.0, the notion of ACL (Access Control List) has been added allowing you to limit the operations/access to the data based on a key pattern, for the connected user. This will allow you to have a good control of the data and who can see/manipulate them

If you are using MongoDB:

  • you can use multiple collections (tables), for example, prefixing the collection name with a context.
  • or you can use a composite key, where one of the fields will be your context

In both cases, for Redis and MongoDB, you are kind of creating using business logic the concept of "database".

If you provide more details/examples, the community can probably give you a more detailed answer.

Related