O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Learning Couchbase

Book Description

Design documents and implement real world e-commerce applications with Couchbase

About This Book

  • Get acquainted with Couchbase architecture and design your document-based data schema
  • Implement full text search using industry standard elastic search plugins
  • Develop critical and high performance applications using this hands-on tutorial guide

Who This Book Is For

If you are new to the NoSQL document system or have little or no experience in NoSQL development and administration and are planning to deploy Couchbase for your next project, then this book is for you. It would be helpful to have a bit of familiarity with Java.

What You Will Learn

  • Get acquainted with the concept of NoSQL databases and configure your Couchbase database cluster
  • Maintain Couchbase effectively using the web-based administrative console with ease
  • Enable partition capabilities by making use of Buckets
  • Analyze important design considerations for maintaining relationship between various documents
  • Use Couchbase SDK Java API to store and retrieve document
  • Write views using map/reduce to retrieve documents efficiently
  • Get familiar with N1QL and how to use it in Java applications
  • Integrate Couchbase with Elasticsearch to implement full text search
  • Configure XDCR for disaster recovery and develop ecommerce application using Couchbase

In Detail

NoSQL database systems have changed application development in terms of adaptability to dynamics schema and scalability. Compared with the currently available NoSQL database systems, Couchbase is the fastest. Its ease of configuration and powerful features for storing different schema structures, retrieval using map reduce and inbuilt disaster recovery by replicating document across the geographical region, make it one of the most powerful, scalable and comprehensive NoSQL in the market. Couchbase also introduces smart client API for various programming language to integrate the database with the application easily, yet providing very complex features like cluster health awareness.

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.

Style and approach

The book starts from absolute basics and slowly moves to more advanced topics ensuring at every step that all concepts and terms are understood by the reader to have complete understanding at every stage. Technical and complex terms are explained in clear and simple language, thus making this book a perfect companion for those who have started their journey to NoSQL using Couchbase

Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the code file.

Table of Contents

  1. Learning Couchbase
    1. Table of Contents
    2. Learning Couchbase
    3. Credits
    4. About the Author
    5. About the Reviewers
    6. www.PacktPub.com
      1. Support files, eBooks, discount offers, and more
        1. Why subscribe?
        2. Free access for Packt account holders
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Errata
        3. Piracy
        4. Questions
    8. 1. Introduction to Couchbase
      1. What is NoSQL and why do we need it?
        1. So what is NoSQL?
        2. Why do we need NoSQL?
      2. The architecture of Couchbase
        1. Data manager
        2. Cluster management
      3. Concepts of Couchbase
        1. Buckets
        3. Cross Data Center Replication
        4. Installation on Windows and Linux environments
        5. Couchbase installation on Red Hat, CentOS, and others
        6. Startup and shutdown
          1. On Linux
          2. On Windows
        7. Understanding log and configuration files
          1. debug
          2. info
          3. error
          4. mapreduce_errors
          5. reports.log
          6. Mobile development with Couchbase Lite
      4. Summary
    9. 2. The Couchbase Administration Interface
      1. The need for the Couchbase administrative interface
      2. The web admin UI
      3. Buckets and servers
        1. Server nodes
        2. Data buckets
      5. XDCR
      6. Log
      7. Settings
      8. Couchbase administrative REST API
      9. The command line interface
      10. Summary
    10. 3. Storing Documents in Couchbase Using Buckets
      1. Buckets
        1. Types of bucket
          1. Memcached
          2. Couchbase
      2. Understanding documents
        1. Keys and metadata
      3. vBuckets
      4. Understanding some internals of Couchbase
        1. Ejection
        2. Warmup
        3. Replication
          1. Server settings
          2. Bucket settings
        4. Rebalancing
      5. Summary
    11. 4. Designing a Document for Couchbase
      1. Understanding JSON and non JSON data
        1. A shopping cart – understanding data types
      2. Document versus RDBMS
      3. Document modeling
        1. One document versus multiple documents
          1. User
          2. Order
      4. Document relationships
        1. User and Order
      5. Using the document editor
        1. User
        2. Order
      6. Summary
    12. 5. Introducing Client SDK
      1. A Couchbase SDK overview
      2. Understanding write operation in the Couchbase cluster
        1. Understanding update operations in the Couchbase cluster
        2. Understanding read operation in the Couchbase cluster
      3. Understanding the Couchbase API
        1. CRUD operations using the Couchbase API
          1. Create
          2. Read
          3. Update
          4. Delete
      4. Understanding Java SDK
        1. CRUD operations using the Java SDK
          1. Insert
          2. Read
          3. Update
          4. Upsert
          5. Delete
          6. Touch
        2. Implementation – a Maven project for CRUD operations using the Java SDK
      5. Understanding locking
        1. Get with Lock (GETL)
        2. CAS
      6. Understanding counters
      7. async operations
      8. Connection management
      9. Summary
    13. 6. Retrieving Documents without Keys Using Views
      1. An overview of MapReduce
        1. Types of views
          1. Development
          2. Production
        2. A view's life cycle
        3. The views editor
        4. Accessing a view using Java API
      3. Indexes
      4. Understanding stale parameters
      5. Built-in reduce functions
        1. count
        2. sum
        3. stats
      6. Custom reduce functions
      7. Filtering and transforming data
        1. Using keys
        2. Pagination
        3. Grouping
        4. Ordering
      8. Mapping with SQL to MapReduce
        1. Select and where conditions
        2. Order by
        3. Group by
      9. Understanding geospatial views
      10. View writing guidance
      11. Summary
    14. 7. Understanding SQL-Like Queries – N1QL
      1. The N1QL overview
        1. Installing and configuring N1QL
        2. The N1QL query engine
      2. Operation types
      3. Understanding N1QL syntax
        1. Join
        2. Cross-bucket joins
        3. Query conditions and expressions
        4. Sorting and grouping
      4. Indexing properties
        1. Explaining a query
      5. Using the N1QL API
      6. Summary
    15. 8. Full Text Search Using ElasticSearch
      1. Understanding content-driven applications
      2. Full text search overview
      3. Configuration and query
      4. Using the ES query API
      5. An API to connect to ES
      6. Summary
    16. 9. Data Replication and Compaction
      1. Understanding the XDCR architecture
        1. Active-active conflict resolution
      2. Configuration and monitoring
        1. CAPI-mode XDCR
        2. XMEM-mode XDCR
      3. Monitoring ongoing replications
      4. The detailed replication progress
      5. XDCR use cases
      6. XDCR topologies
        1. Unidirectional
        2. Bidirectional
      7. XDCR impact
      8. Compaction
        1. The compaction process
        2. The compaction configuration
      9. Summary
    17. 10. Administration, Tuning, and Monitoring
      1. Overview
      2. Backup and restoration
      3. cbbackup
        1. Backing up all nodes and all buckets
        2. Backing up all nodes for a single bucket
        3. Backing up a single node for a single bucket
        4. Restoring using the cbrestore tool
        5. Backing up the Couchbase cluster using file copies
      4. Rebalancing
      5. Adding and removing a node from the cluster
      6. Performing a bulk set
      7. Monitoring
        1. Monitoring startup
        2. Monitoring the disk write queue
      8. Best practices
        1. Cluster design
        2. Sizing
        3. Hardware
      9. Summary
    18. 11. Case Study – An E-Commerce Application
      1. Overview
      2. The conceptual model
        1. Customer
        2. Category/catalog
        3. Product
        4. Cart
        5. Order
          1. Getting all products for a category
          2. Getting all orders for a particular customer
          3. Getting the cart for a customer
      3. Summary
    19. Index