Buckets, Scopes, and Collections

  • Capella Operational
  • concept
The data in a Couchbase Capella cluster is categorized and organized into different data containers. These data containers hold documents, which hold JSON key-value pairs that define your data.

Capella clusters have 3 types of data containers:

Diagram

Use the hierarchy of buckets, scopes, and collections to categorize and organize your data for quick and easy retrieval.

Store documents in collections and group similar collections with scopes. For example, you could use scopes and collections to group data in a travel application:

Diagram
You can create new buckets, scopes, and collections when you import data into your cluster. For more information, see Import Data with the Capella UI.

Buckets

Buckets are the top-level storage containers for data in a Capella cluster.

You must create a bucket before you can store any data in your cluster. A Capella cluster can have a maximum of 30 buckets.

Diagram

Bucket Types

Capella has two distinct bucket types:

  • Memory and Disk: The bucket holds data in-memory and persists it to disk.

  • Memory Only: The bucket holds data in-memory but does not persist it to disk.

    Memory Only buckets lose data during cluster restarts, whether planned or unplanned, and may also lose data due to concurrent failure of multiple nodes.

For a detailed overview of buckets, see Buckets in the Couchbase Server documentation.

Buckets and Storage

Couchbase Capella operational clusters store document data and metadata in append-only files. This format ensures consistent updates to files and reduces the risk of corruption. Every file change, including additions, modifications, or deletions, creates a new entry at the end of the file. Even when document deletion removes user data, the file temporarily grows in size because of the append-only format.

Capella periodically reduces file sizes through automated compaction. Automated compaction purges metadata items and runs other necessary maintenance tasks. During compaction, Capella removes any item marked as a deleted item, or tombstone, when its age exceeds a set purge age. The delay for deleting tombstones is necessary for replication consistency.

Automated compaction tasks and purging automatically run on Capella buckets. When database fragmentation reaches 30% for Couchstore buckets and 50% for Magma buckets, Capella triggers its automated compaction. Capella purges any items marked for deletion, or tombstones, that are more than 3 days old. A dedicated purge task also runs purging for Memory-Only buckets.

If the cluster links to an App Service, deleted or tombstoned documents remain in buckets for 60 days. This allows disconnected clients to sync deleted documents when they come back online within the 60 day window.

You must provision a Memory Only bucket with enough memory to be able to restore from backups. For more information about backup and restore, see Backup and Restore Data.

For more information about how to create a new bucket, see Create a Bucket.

Scopes

A scope is a data container that exists inside a Capella bucket. Use scopes to group related collections.

Each scope must contain at least 1 collection. A cluster can hold up to 1000 collections, and you can spread this number across multiple scopes and buckets. Buckets are also limited to 1 collection per MB of memory quota.

Diagram

For more information about how to create a new scope, see Create a Scope.

_default Scope

When you create a bucket in your Capella cluster, a _default scope and collection are automatically created within that bucket. Any document that you create without a specific scope and collection is assigned to the _default scope and collection.

You cannot delete the _default scope.

_system Scope

The _system scope is part of all clusters using Couchbase Server 7.6 or later. When you upgrade a cluster to Couchbase Server 7.6, Capella adds the _system scope to your existing buckets.

All sample buckets and buckets that you create include a _system scope. The _system scope contains the _mobile and _query collections that store system documents for related Couchbases services.

The _system scope and its collections are read-only, and their structure is subject to change without notice. Do not use these collections for other purposes.

You cannot remove the _system scope or its collections.

Collections

A collection is a data container that exists inside a Capella scope. It’s the smallest container that holds the documents inside a bucket.

Each cluster can have a maximum of 1000 collections. You can spread this number of collections across multiple scopes and buckets. Buckets are also limited to 1 collection per MB of memory quota.

Diagram

For more information about how to create a new collection, see Create a Collection.

_default Collection

When you create a bucket in your Capella cluster, a _default collection is automatically created within your _default scope. Any document that you create without a specific scope and collection is assigned to the _default scope and collection.

You can delete the _default collection from the _default scope using the Couchbase Capella UI, API, SDKs, or queries. While you can delete the _default collection, there is no actual advantage to this. The _default collection is there to help group and organize documents without a set scope. If you decide to delete it, you’ll not be able to recreate or recover it later.

Linking Collections

You must link collections to your App Endpoints to use data contained within them for your mobile and IoT applications. For more information about collection linking and unlinking, see linking a collection.