From SQL to NoSQL

Hi,

First, you should see a bucket more like a database than a table. It’s easier to have products and users in the same bucket.

Here are some links about Data Modeling that should help you:

http://blog.couchbase.com/three-things-know-about-document-database-modelling-part-1
http://blog.couchbase.com/data-modelling-when-embed-or-refer
http://blog.couchbase.com/manual-secondary-indexes
http://blog.couchbase.com/data-modelling-key-design

  1. Indeed creating a view is a solution.
  2. To fetch all the products of a user, you indeed have to fetch every products using their Ids from the user.products field. It’s easy to do a bulk get with our SDKs. Remember that doing a key/value get is fast. Don’t be afraid to hit the database with this. It’s not a query.
  3. Unfortunately when you start denormalizing data, this becomes something you actually have to do. In the future you might be able to do this with a N1QL query. But right now you do have to update the Users.
1 Like