ODBC Driver for Couchbase

Build 23.0.8839

カスタムスキーマ定義

自動スキーマ検出 に加え、本製品 ではCouchbase オブジェクトのスキーマを統計的に定義することができます。 スキーマは、容易に拡張できるテキストベースのコンフィギュレーションファイルで定義されます。CreateSchema ストアドプロシージャを呼び出してスキーマファイルを生成できます。詳しくは、自動スキーマ検出 を参照してください。

Location プロパティをスキーマファイルを格納するファイルディレクトリに設定します。次のセクションでは、結果のスキーマを拡張する方法や自分で記述する方法について説明します。

サンプルドキュメント

次のドキュメントを考え、ネストプロパティを独自のカラムとして取得してみましょう:

/* Primary key "1" */
{
  "id": 12,
  "name": "Lohia Manufacturers Inc.",
  "homeaddress": {"street": "Main "Street", "city": "Chapel Hill", "state": "NC"},
  "workaddress": {"street": "10th "Street", "city": "Chapel Hill", "state": "NC"}
  "offices": ["Chapel Hill", "London", "New York"]
  "annual_revenue": 35600000
}
/* Primary key "2" */
{
  "id": 15,
  "name": "Piago Industries",
  "homeaddress": {street": "Main Street", "city": "San Francisco", "state": "CA"},
  "workaddress": {street": "10th Street", "city": "San Francisco", "state": "CA"}
  "offices": ["Durham", "San Francisco"]
  "annual_revenue": 42600000
}

カスタムスキーマ定義


<rsb:info title="Customers" description="Customers" other:dataverse="" other:bucket=customers"" other:flavorexpr="" other:flavorvalue="" other:isarray="false" other:pathspec="" other:childpath="">
  <attr name="document.id"        xs:type="string"  key="true" other:iskey="true" other:pathspec=""  />
  <attr name="annual_revenue"     xs:type="integer" other:iskey="false"           other:pathspec=""  other:field="annual_revenue" />
  <attr name="homeaddress.city"   xs:type="string"  other:iskey="false"           other:pathspec="{" other:field="homeaddress.city" />
  <attr name="homeaddress.state"  xs:type="string"  other:iskey="false"           other:pathspec="{" other:field="homeaddress.state" />
  <attr name="homeaddress.street" xs:type="string"  other:iskey="false"           other:pathspec="{" other:field="homeaddress.street" />
  <attr name="name"               xs:type="string"  other:iskey="false"           other:pathspec=""  other:field="name" />
  <attr name="id"                 xs:type="integer" other:iskey="false"           other:pathspec=""  other:field="id" />
  <attr name="offices"            xs:type="string"  other:iskey="false"           other:pathspec=""  other:field="offices" />
  <attr name="offices.0"          xs:type="string"  other:iskey="false"           other:pathspec="[" other:field="offices.0" />
  <attr name="offices.1"          xs:type="string"  other:iskey="false"           other:pathspec="[" other:field="offices.1" />
  <attr name="workaddress.city"   xs:type="string"  other:iskey="false"           other:pathspec="{" other:field="workaddress.city" />
  <attr name="workaddress.state"  xs:type="string"  other:iskey="false"           other:pathspec="{" other:field="workaddress.state" />
  <attr name="workaddress.street" xs:type="string"  other:iskey="false"           other:pathspec="{" other:field="workaddress.street" />
</rsb:info>
カスタムスキーマ例 では、上の例を含む完全なスキーマを確認できます。

テーブルプロパティ

上のスキーマは次のプロパティを使って、すべてのテーブルの特定のquality を定義します。すべて必須です。

プロパティ 説明
other:dataverse データセットが属するDataverse の名前。Analytics ビューでない場合は空です。
other:bucket Couchbase 内のバケットまたはデータセットの名前。
other:flavorexpr フレーバーテーブル内のURL エンコード条件。例えば"%60docType%60%20%3D%20%22chess%22"。
other:flavorvalue フレーバーテーブル内のフレーバーの名前。例えば"chess"。
other:isarray テーブルが配列の子テーブルかどうか。
other:pathspec これは、other:childpath 内の区切り文字を解釈するために使用されます。詳しくはColumn Properties を参照してください。
other:childpath 子テーブルのUNNEST に使用される属性へのパス。子テーブルでない場合は空です。

カラムプロパティ

上のスキーマは次のプロパティを使って、それぞれのカラムの特定のquality を定義します:

プロパティ 説明
name 必須。カラムの名前。小文字。
key 主キーをマークするために使用されます。Document.Id では必須。その他のカラムでは任意。
xs:type 必須。本製品 内のカラムのタイプ。
other:iskey 必須。キーと同じ値、またはキーが含まれていない場合は"false" にする必要があります。
other:pathspec 必須。これは、other:field 内の区切り文字を解釈するために使用されます。
other:field 必須。Couchbase のフィールドへのパス。

垂直方向のフラット化によって生成されるフィールドは、配列値とフィールド値を分離するために同じ構文を使用します。これにより、本製品 が"numeric_object.0" と"array.0" を公開するような場合にあいまいさが生じる可能性があります。

{
  "numeric_object": {
    "0": 0
  },
  "array": [
    0
  ]
}
本製品 がフィールドアクセスと配列アクセスを区別できるようにするために、pathspec はフィールド内の各"." が配列かオブジェクトかを判断するために使用されます。各"{" はフィールドアクセスを表し、各"[" は配列アクセスを表します。

例えば、フィールドが"a.0.b.1" で"pathspec" が"[{[" の場合、N1QL 式"a[0].b[1]" が生成されます。代わりに"pathspec" が"{{{" だった場合は、N1QL 式"a.`0`.b.`1`" が生成されます。

Copyright (c) 2024 CData Software, Inc. - All rights reserved.
Build 23.0.8839