Teiid Couchbase Connector
Defining a Schema
The data stored in Couchbase are JSON documents, each document may contain:
- key pair with no typed value
- nested arrays
- arrays of differently-typed elements
- nested documents which contain above 3 scenarios
which does not follow the rules of data typing and structure that apply to traditional relational tables and columns. To map the documents to a relational form, the Teiid Couchbase connector will generates a database schema that maps the Couchbase data to a JDBC-compatible format. Simply, this be done in Teiid Connector’s MetadataProcessor load the Metadata.
Principles for mapping documents to JDBC-compatible Tables
- The keyspace/bucket be mapped as top table which contains all key/value pairs not include the nested arrays/documents, key be mapped to column name, the value type be mapped to column type
- The nested arrays/documents be mapped to different table with name:
the parent table
+underscore character
+the key of nested arrays/documents
- Each Table has a PK column map the document id, the PK in top table is primary key.
- If a nested array has a nested array item, the array item item be treated as Object.
An Example of Schema Definition
There are documents Customer
and Order
under Bucket test
:
Customer
Order
Mapped table relations
The above documents will map to 4 tables: test
, test_CreditCard
, test_Items
, test_SavedAddresses
.