資料庫對應 database-mapping

範例結構描述的SQL對應提供下列XML檔案:

<schema mappingType="sql" name="recipient" namespace="cus" xtkschema="xtk:schema">
  <enumeration basetype="byte" name="gender">
    <value label="Not specified" name="unknown" value="0"/>
    <value label="Male" name="male" value="1"/>
    <value label="Female" name="female" value="2"/>
  </enumeration>

  <element name="recipient" sqltable="CusRecipient">
    <attribute desc="Recipient e-mail address" label="Email" length="80" name="email" sqlname="sEmail" type="string"/>
    <attribute default="GetDate()" label="Date of creation" name="created" sqlname="tsCreated" type="datetime"/>
    <attribute enum="gender" label="Gender" name="gender" sqlname="iGender" type="byte"/>
    <element label="Location" name="location">
      <attribute label="City" length="50" name="city" sqlname="sCity" type="string" userEnum="city"/>
    </element>
  </element>
</schema>

說明 description

結構描述的根元素已不存在 <srcschema>,但 <schema>.

這會將我們帶到另一種型別的檔案,該檔案是從來源結構描述自動產生的,簡稱為結構描述。 Adobe Campaign應用程式將使用此結構描述。

SQL名稱是根據元素名稱和型別自動決定的。

SQL命名規則如下:

  • 表格:串連綱要名稱空間和名稱

    在我們的範例中,表格的名稱是透過以下結構描述的主要元素輸入: sqltable 屬性:

    code language-sql
    <element name="recipient" sqltable="CusRecipient">
    
  • 欄位:前面有根據型別定義之前置詞的元素名稱('i'代表整數,'d'代表雙精度浮點數,'s'代表字串,'ts'代表日期等)

    欄位名稱是透過 sqlname 每個型別的屬性 <attribute><element>

    code language-sql
    <attribute desc="E-mail address of recipient" label="Email" length="80" name="email" sqlname="sEmail" type="string"/>
    
NOTE
可以從來源結構描述多載SQL名稱。 若要這麼做,請在相關元素上填入「sqltable」或「sqlname」屬性。

用來建立從擴充綱要產生之表格的SQL命令檔如下:

CREATE TABLE CusRecipient(
  iGender NUMERIC(3) NOT NULL Default 0,
  sCity VARCHAR(50),
  sEmail VARCHAR(80),
  tsCreated TIMESTAMP Default NULL);

SQL欄位限制如下:

  • 數值和日期欄位中沒有null值
  • 數值欄位已初始化為0

XML欄位 xml-fields

依預設,任何輸入的 <attribute><element> 元素對應至資料結構描述表格的SQL欄位。 不過,您可以用XML來參照此欄位,而非SQL,這表示資料會儲存在包含所有XML欄位值的表格之備忘錄欄位(「mData」)中。 這些資料的儲存是觀察結構描述結構的XML檔案。

若要以XML填入欄位,您必須新增 xml 對相關元素具有「true」值的屬性。

範例

  • 多行註解欄位:

    code language-sql
    <element name="comment" xml="true" type="memo" label="Comment"/>
    
  • HTML格式的資料說明:

    code language-sql
    <element name="description" xml="true" type="html" label="Description"/>
    

    「html」型別可讓您將HTML內容儲存在CDATA標籤中,並在Adobe Campaign使用者端介面中顯示特殊的HTML編輯檢查。

使用XML欄位可讓您新增欄位,而不需要修改資料庫的實體結構。 另一個優點是,您使用的資源較少(配置給SQL欄位的大小、限制每個表格的欄位數等)。

recommendation-more-help
35662671-8e3d-4f04-a092-029a056c566b