Share via


Tables Element (OrderObjectMappings.Xml File)

For the latest version of Commerce Server 2007 Help, see the Microsoft Web site.

The Tables element in the OrderObjectMappings.xml file identifies the database tables and columns that PurchaseOrder instances are mapped to.

The Tables element is a child of the StorageMap element, and is required. It is a container for Table elements.

Table Element

The Table element identifies a table in the transactions resource database. The Table element contains the following elements: the Columns element, the Constraints element, and the Ordering element.

The following table lists the attributes of the Table element.

Attribute

Data Type

Description

Name

String

The name of a table in the transactions resource database.

This attribute is required.

Owner

String

The owner of the table.

This attribute is optional. The default value is "dbo".

Columns Element

The Columns element is a container for Column elements.

Column Element

The Column element identifies a column in a table.

The following table lists the attributes of the Column element.

Attribute

Data Type

Description

Name

String

The name of a column in the table.

This attribute is required.

DataType

String

The SQL Server type of the column.

This attribute is required.

Bb219231.alert_note(en-US,CS.70).gifNote:
Do not use the text, vchar, or char SQL Server types. Use the ntext, nvchar, and nchar types instead.

Precision

Integer

The width of the column. This attribute is used only if the value of the DataType attribute is "nvchar" or "decimal".

This attribute is optional. The default value is 0 (zero).

Scale

Integer

The number of digits after the decimal point. This attribute is used only if the value of the DataType attribute is "decimal".

This attribute is optional. The default value is 0 (zero).

IsNullable

Boolean

Whether the column may have a null value. Use the value false if the column is defined with the not null constraint in the database.

This attribute is optional. The default value is false.

GUID

Boolean

Whether the column has the rowguid SQL Server property set to true.

This attribute is optional. The default value is false.

Bb219231.alert_note(en-US,CS.70).gifNote:
Only one column in a table can have a GUID attribute with a value of true.

Constraints Element

The Constraints element describes the constraints on the table. This element is required. The Constraints element contains the following elements: the PrimaryKey element, the ForeignKey element, and the Unique element.

PrimaryKey Element

The PrimaryKey element identifies the primary key of a table. This element is required. The set of PrimaryKey elements in a Table element must reflect the primary key of the table as defined in the database schema.

The PrimaryKey element contains one or more ColumnRef elements.

The following table lists the attributes of the PrimaryKey element.

Attribute

Data Type

Description

Name

String

The name of the primary key constraint. This value must match the name of the constraint in the database schema.

This attribute is optional.

Clustered

Boolean

Whether the constraint's clustered property is set in the database.

This attribute is optional. The default value is true.

ColumnRef Element

The ColumnRef element identifies the database column that is involved in a constraint.

The following table lists the attributes of the ColumnRef element.

Attribute

Data Type

Description

Name

String

The name of the column.

This attribute is required.

ForeignKey Element

The ForeignKey element identifies a foreign key constraint on a table. This element is optional. The set of ForeignKey elements in a Table element must reflect the foreign-key constraints of the table as defined in the database schema.

The ForeignKey element contains one or more ColumnMatch elements.

The following table lists the attributes of the ForeignKey element.

Attribute

Data Type

Description

Name

String

The name of the foreign-key constraint. This value must match the name of the constraint in the database schema.

This attribute is optional.

ForeignTable

String

The name of the table from which the foreign key is copied. This attribute is required.

CascadeDelete

Boolean

Whether on delete cascade is defined for this constraint in the database.

This attribute is optional. The default value is false.

CascadeUpdate

String

Whether on update cascade is defined for this constraint in the database.

This attribute is optional. The default value is false.

ColumnMatch Element

The ColumnMatch element identifies a mapping between a foreign-key column of this table and the column of the foreign-key table from which the key value is copied. The following table lists the attributes of the ColumnMatch element.

Attribute

Data Type

Description

Name

String

The name of the column that contains the foreign key.

This attribute is required.

ForeignName

String

The name of the column in the foreign-key table that provides the foreign-key value.

This attribute is required.

Unique Element

The Column element identifies a unique constraint on a table. This element is optional.

The Unique element contains one or more ColumnRef elements.

The following table lists the attributes of the Unique element.

Attribute

Data Type

Description

Name

String

The name of the column for which the unique constraint is enforced.

This attribute is required.

Clustered

Boolean

Whether the constraint's clustered property is set in the database.

This attribute is optional. The default value is false.

Ordering Element

The Ordering element is a container for OrderBy elements. This element is optional.

OrderBy Element

The OrderBy element specifies how to order the members of a collection when the collection is retrieved.

The following table lists the attributes of the OrderBy element.

Attribute

Data Type

Description

Column

String

The name of a column that maps to a collection.

This attribute is required.

Ascending

String

Whether the lowest value in the column should be the first item in the collection.

This attribute is optional. The default value is false, which means that the first item in the collection will have the highest value for the column.

Example

<StorageMap>
  <Tables>
    <Table Name="PurchaseOrders">
      <Columns>
        <Column Name="OrderGroupId" DataType="uniqueidentifier" 
          GUID="true" />
        <Column Name="Name" DataType="nvarchar" Precision="64" 
          IsNullable="true" />
        <Column Name="SoldToId" DataType="uniqueidentifier" />
        <Column Name="SoldToAddressId" DataType="nvarchar" 
          Precision="50" IsNullable="true" />
        <Column Name="LineItemCount" DataType="int" />
        <Column Name="ShippingTotal" DataType="money" />
        <Column Name="LastModified" DataType="datetime" />
        <Column Name=" MessageToRecipient " DataType="nvarchar" 
          Precision="64" IsNullable="true" />
        <Column Name="MarshalledData" DataType="image" 
          IsNullable="true" />
      </Columns>
      <Constraints>
        <PrimaryKey Name="PK_PurchaseOrders">
          <ColumnRef Name="OrderGroupId" />
        </PrimaryKey>
      </Constraints>
    </Table>
    <Table Name="LineItems">
      <Columns>
        <Column Name="LineItemId" DataType="uniqueidentifier" 
          GUID="true" />
        <Column Name="OrderFormId" DataType="uniqueidentifier" />
        <Column Name="LineItemOrdering" DataType="timestamp" 
          IsNullable="true" />
        <Column Name="MarshalledData" DataType="image" 
          IsNullable="true" />
      </Columns>
      <Constraints>
        <PrimaryKey Name="PK_LineItems">
          <ColumnRef Name="LineItemId" />
        </PrimaryKey>
        <ForeignKey Name="FK_LineItems_OrderForms" 
          ForeignTable="OrderForms" CascadeDelete="false">
          <ColumnMatch Name="OrderFormId" ForeignName="OrderFormId" />
        </ForeignKey>
      </Constraints>
      <Ordering>
        <OrderBy Column="OrderFormId" Ascending="true" />
        <OrderBy Column="LineItemOrdering" Ascending="true" />
      </Ordering>
    </Table>
  </Tables>
...
</StorageMap>

See Also

Other Resources

Mapping Purchase Orders to the Database

StorageMap Element (OrderObjectMappings.Xml File)