Query and Modify Data in Couchbase with N1QL

Paths

Query and Modify Data in Couchbase with N1QL

Author: Kishan Iyer

N1QL (pronounced “nickle”) is a declarative query language intended to adapt the widely-known SQL language to apply more naturally to JSON. In this skill, you will learn the basic... Read more

What You Will Learn

  • Query data using N1QL
  • Combine and aggregate data using N1QL
  • Modify data using N1QL
  • Proper application and use of indexes
  • Tuning N1QL queries for optimal performance

Pre-requisites

  • JSON
  • Javascript
  • Document database literacy

Beginner

Learn to build and run N1QL queries, and filter data.

Query Data from Couchbase Using N1QL

by Kishan Iyer

Jan 30, 2020 / 3h 44m

3h 44m

Start Course
Description

Couchbase is a document-oriented database which has its own query language, called N1QL to view and manipulate data. In this course, Query Data from Couchbase Using N1QL, you will get some hand-on experience in writing N1QL queries whose syntax is similar to SQL but is meant to work with JSON documents. First, you will explore how documents can be searched using the Couchbase web UI and how this interface allows you to define filters based on a document key and also on the values of its attributes. Next, you will cover some of the basics of querying in the N1QL query language - such as the SELECT, FROM and WHERE clauses of a N1QL query - and will also take a brief look at adding and updating documents using INSERT and UPDATE queries. Finally, you will discover how to work with data at a document level, and also perform aggregate operations using the GROUP BY and HAVING clauses. You will then gain an understanding on the use of built-in functions in N1QL, the building of indexes and the use of conditional operators such as the CASE statement. Once you finish this course, you will have a broad understanding of the capabilities of Couchbase and N1QL and can run a variety of queries on your document data.

Table of contents
  1. Course Overview
  2. Getting Started with Queries
  3. Selecting and Filtering Query Results
  4. Indexing and Shaping Query Results
  5. Invoking Functions in Queries
  6. Performing Conditional Operations in Queries

Filter Data from Couchbase Using N1QL

by Kishan Iyer

Dec 31, 2019 / 3h 15m

3h 15m

Start Course
Description

There are a variety of ways to filter queries in Couchbase. In this course, Filter Data from Couchbase Using N1QL, you will get some hands on experience in writing queries to retrieve documents from a Couchbase database using filters you have defined. These queries will be written in the N1QL query language which has a SQL-like syntax to work with JSON data.

First, you will explore how documents can be searched using the Couchbase web UI and how this interface allows you to define filters based a document key and also on the values of its attributes.

Next, you will cover some of the basics of querying in the N1QL query language - such as the SELECT, FROM and WHERE clauses of a N1QL query - and will also take a brief look at adding and updating documents using INSERT and UPDATE queries. Then, you will move on to the filtering of documents based on the values of their attributes using a variety of comparison operators.

Finally, you will delve into filtering documents based on the contents of nested structures such as arrays and objects. This includes the use of collection operators, invoking built-in array functions and also generating slices of arrays.

By the end of this course, you will have the skills required to run a variety of filter queries on the data you have stored in a Couchbase database.

Table of contents
  1. Course Overview
  2. Performing Filter Queries Using the Web Interface
  3. Getting Started with N1QL Filter Queries
  4. Filtering Documents with N1QL
  5. Filtering Nested Structures and Collections with N1QL

Intermediate

Aggregate data across documents, and apply indexes to boost query performance.

Combine and Aggregate Data from Couchbase Using N1QL

by Kishan Iyer

Feb 8, 2020 / 3h 5m

3h 5m

Start Course
Description

Want to learn about combining and aggregating data from multiple related documents using the N1QL query language? In this course, Combine and Aggregate Data from Couchbase Using N1QL, you will get some hands-on experience in writing queries which combine and aggregate the contents of related documents. These queries will be written in the N1QL query language which has a SQL-like syntax but is meant to work with JSON data. First, you will explore how data from different related documents can be combined by performing a JOIN operation, and a variety of joins will be covered in the course including left and right joins. You will also get to combine a collection of matching documents into an array using the NEST operation and will also learn to unpack a nested array using UNNEST. Beyond that, you will discover some aggregate operations which can be performed in N1QL using the GROUP BY and HAVING clauses, and will use the LETTING keyword to declare variables which can be referenced in a HAVING clause. Finally, you will perform a few set operations in N1QL such as UNION, INTERSECT, and EXCEPT. By the end of this course, you will have the skills required to run a variety of queries which can combine and aggregate data stored in documents.

Table of contents
  1. Course Overview
  2. Combining Documents Using Simple Joins
  3. Exploring Different Kinds of Joins in N1QL
  4. Working with Arrays Using Nest and Unnest Operations
  5. Aggregating Data Using Grouping and Set Operations

Improve N1QL Query Performance Using Indexes

by Kishan Iyer

Mar 10, 2020 / 4h 26m

4h 26m

Start Course
Description

Indexes are a very interesting feature in any database, and this is also true of Couchbase. In this course, Improve N1QL Query Performance Using Indexes, you will cover the various kinds of indexes you can create and what kind of N1QL queries they can help with in terms of speeding up their execution.

First, you will begin by exploring the most basic kinds of indexes which are known as primary indexes. Next, you will look at secondary indexes containing just a single field and how one or more of them can be used by a N1QL query to improve performance. Then, you will move on to composite indexes containing multiple fields and discuss their benefits and limitations. Finally, you will glimpse the Analytics Service in Couchbase which allows you to run queries against the data in a bucket by splitting them up into datasets of similar documents.

Once you are done with this course, you will be quite the expert in the different kinds of indexes available in Couchbase, and how they can be applied to improve the performance of your N1QL queries.

Table of contents
  1. Course Overview
  2. Getting Started with Indexes
  3. Creating Secondary Indexes in Couchbase
  4. Building Complex Secondary Indexes
  5. Implementing Different Types of Indexes
  6. Understanding Factors That Affect Query Performance
  7. Distributing Query Execution Loads with Pushdowns
  8. Optimizing Query Execution

Advanced

Use N1QL to modify data, and learn how to optimize your N1QL queries for performance.

Modify Data in Couchbase Using N1QL

by Kishan Iyer

Mar 2, 2020 / 2h 22m

2h 22m

Start Course
Description

Are you looking for different ways to alter document data in Couchbase? In this course, Modify Data in Couchbase Using N1QL, we look at different ways in which document data can be added to Couchbase, modified, and also removed using the N1QL query language. First, you will cover the different kinds of statements which N1QL provides in order to perform data modifications. You then delve into the use of INSERT statements to add one or more documents to Couchbase buckets and examine the role-based access control feature of Couchbase, specifically, the assignment of permissions to users to run N1QL queries performing INSERT operations. Next, with the addition of entire documents, you will discover how individual attributes can be added to, modified or removed from existing documents using the UPDATE statement. You will also cover the use of UPSERT statements which are a combination of INSERT and UPDATE statements. You will also explore the use of DELETE statements in order to remove documents which are no longer required. Finally, once you are familiar familiar with different ways to modify data, you will cover the use of MERGE statements to define which data needs to be added, modified or removed based on the results of a join operation. Once you are done with this course, you will have the skills required to perform any kind of data modification on your Couchbase document data using the N1QL query language.

Table of contents
  1. Course Overview
  2. Creating Data with N1QL
  3. Manipulating Data with N1QL
  4. Modifying Data with N1QL
  5. Deleting Data with N1QL

Optimize N1QL Queries

by Kishan Iyer

Mar 20, 2020 / 3h 7m

3h 7m

Start Course
Description

The N1QL query language in Couchbase is very powerful and allows a wide variety of operations on document data. Given that, it becomes crucial to understand how exactly queries are executed in order to run them in the most optimal manner. In this course, Optimize N1QL Queries, you'll explore the different ways in which N1QL query executions can be optimized. First, you'll begin by looking into what query plans are, the different phases involved in the execution of N1QL queries, and the various Couchbase services which participate in query executions. Next, you'll delve into the role of indexes in running N1QL queries and build a variety of secondary indexes to speed up query executions. Then, you'll create prepared statements to further optimize queries - by skipping the step of generating query plans for each execution. Finally, you'll discover how monitoring can help us analyze queries which are active and also those which have completed execution. Once you’re done with this course, you'll have a thorough understanding of the various factors which influence query performance in Couchbase, and the tools available to execute them in an optimal manner.

Table of contents
  1. Course Overview
  2. Understanding Query Optimization
  3. Analyzing the Role of Indexes in Query Executions
  4. Optimizing Executions with Indexes and Prepared Statements
  5. Monitoring N1QL Queries
  6. Implementing Replication in Couchbase
Offer Code *
Email * First name * Last name *
Company
Title
Phone
Country *

* Required field

Opt in for the latest promotions and events. You may unsubscribe at any time. Privacy Policy

By providing my phone number to Pluralsight and toggling this feature on, I agree and acknowledge that Pluralsight may use that number to contact me for marketing purposes, including using autodialed or pre-recorded calls and text messages. I understand that consent is not required as a condition of purchase from Pluralsight.

By activating this benefit, you agree to abide by Pluralsight's terms of use and privacy policy.

I agree, activate benefit