Book Image

Learning Couchbase

By : Henry Potsangbam
Book Image

Learning Couchbase

By: Henry Potsangbam

Overview of this book

This book achieves its goal by taking up an end-to-end development structure, right from understanding NOSQL document design to implementing full fledged eCommerce application design using Couchbase as a backend. Starting with the architecture of Couchbase to get you up and running, this book quickly takes you through designing a NoSQL document and implementing highly scalable applications using Java API. You will then be introduced to document design and get to know the various ways to administer Couchbase. Followed by this, learn to store documents using bucket. Moving on, you will then learn to store, retrieve and delete documents using smart client base on Java API. You will then retrieve documents using SQL like syntax call N1QL. Next, you will learn how to write map reduce base views. Finally, you will configure XDCR for disaster recovery and implement an eCommerce application using Couchbase.
Table of Contents (12 chapters)
Index

The conceptual model


Let's implement the catalog and order process scenarios for our e-commerce application. In our use case, we will be selling only books on the portal that we are going to design. However, if the business wants to expand later to include other products, there will be enough flexibility in this design.

The data model

Our data model is shown in the preceding figure, this is, the database schema. However, in Couchbase, we don't need to create each domain object as a separate entity; the schema of the information goes along with the document. The data model is explained as follows:

  • Customer: This is a model that a user can browse for a product, which can be bought from our application

  • Cart: This represents the namespace to group products that a customer wants to buy

  • Product: This represents books

  • Category: This groups the books into groups such as programming, databases, and so on

For our use case, a customer can have only one cart. In it, the customer can add multiple products...