Migrating from Relational Databases

Migration guidelines for relational database users.
In this section, we use MySQL as an example relational database.

When migrating from MySQL to Couchbase Server, there are several things that you might want to think about, starting with the data model, data types, and feature set differences.

Data Model – Mapping from MySQL to Couchbase Server

Data modeling for RDBMS has been a well-defined discipline for many years.
Professionals, including novice users, have been practicing techniques such as logical to physical mapping and normalization / de-normalization.
However, the old-school RDBMS data modeling techniques still play a meaningful role for those who are new to the NoSQL technology.

Table 1. Concept mapping between MySQL and Couchbase Server

MySQL

Couchbase Server

Database

Bucket

Table

Bucket(s)/Keyspaces

Row

Document

Column

Field

Fixed schema

Flexible schema

Table 2. Datatype mapping between MySQL and Couchbase Server

Data type

MySQL

Couchbase Server

Case sensitive

Yes/No

Yes

Numbers

Yes

Yes

String

Yes

Yes

Boolean

Yes (as tinyint)

Yes

Date time

Yes

Yes (as a string in JSON)

Spatial data

Yes

Yes

MISSING

No

Yes

NULL

Yes

Yes

Object/Arrays

No

Yes

Blobs

Yes

Yes

Feature Set

Like MySQL, Couchbase Server offers a rich set of features and functionality far beyond those offered in simple key-value stores.

With Couchbase Server, you also get an expressive SQL-like query language and query engine called N1QL, which is combined with a new powerful indexing mechanism – Global Secondary Indexes.

Table 3. Feature differences between MySQL and Couchbase Server

Feature

Key difference

Keys/Indexes

Primary keys on keys of (key, value) pair

SQL statements

The result is set in JSON instead of rows and columns.

NEST, UNNEST

Operations on datetime fields require datetime functions in N1QL.

JSON-induced functions in N1QL: JSON, Object, and array functions.

Type and comparison functions.

JOIN, sub-query format differences.

USING KEYS and ON KEYS functions

Explain and metadata

Variation in command and results (JSON).

ETL Tools

You might have a spectrum of relational, operational, and analytical data sources in your environment.
You might also need more sophistication applied to a data movement situation, such as more than just simple extract-load.
In a case like that, you can use an extract-transform-load (ETL) tool such as Talend.
With Talend, you can easily move data between Couchbase Server and any other data source.