SQL Server 2000 and XML For SQL Server 2000 Web Version (SQLXML) provides three ways to store XML data: XML Bulk Load and UpdateGrams, these two client technology uses an annotated outline to specify XML document content and database table Between mappings; OpenXML is a server-side technology that allows you to define a relationship view on an XML document. With OpenXML's relationship view, you can use T-SQL code to query the data in the XML document and store the results in Your SQL Server database.
Each of these three technologies is designed for specific purposes. XML BULK LOAD stores data from a large XML document in SQL Server; UpdateGrams performs optimization updates for SQL Server data (optimized updates are unlocking updates, in which system detection is available in other users It turns out that after reading the data, it changes it); OpenXML provides people's familiar XML data relationship access methods.
In these three technologies, OpenXML is the most flexible because it provides a programming model (T-SQL), where you can use this programming model to write a business in XML data before the XML data is stored in the SQL Server database. Rules or perform calculation logic. However, because OpenXML is a server-based technology, if you use it frequently or have a lot of documentation, it reduces the performance of SQL Server. However, if you use Microsoft .NET Framework Components, you can use ADO.NET's data set to open these performance and scalability, and ADO.NET datasets give you a powerful technology - in order to put XML Data Storage In SQL Server contains a complete programming model.
Data set, data table and XML mapping
You can simply generate XML query results from SQL Server using the data set. By providing a relational data buffer (Cache) that can be used on the client and intermediate layer computer, data can be loaded and maintained in multiple data sources (including SQL Server, other relational databases, and XML).
When you load a dataset from the XML document, the data set must map the data stored in the hierarchical XML performance (representation) to the relationship of the data set. For example, if your XML document contains a list of ORDER elements, it has a nested LineItem element as a child element, then this document is usually mapped into the Orders and LineItems data tables in relational performance. The purpose of this mapping is the same as the method of using the relationship view of the relationship view on the XML document using the XPath query. But different from the XPATH specification, the data set has its own mapping data.
Data Set Use the XML Outline Definition (XSD) Outline to map data from the XML document to the relational data cache of the dataset. The dataset provides you with two ways to specify the outline of mapped XML data. First, you can reference an XSD outline for elements, properties, and relationships that define the XML documents. Another way is that you can directly reason the outline from the structure of the document. In other words, the data set can establish an outline by checking the structure and content of the XML document.
When you reference the XSD outline, the data set uses the element of the element defined in this outline to construct the data table, data column, and data relationships in the relational data cache, and you can use this data cache store to be mapped XML data. When I talk about the structure or outline in the relational data cache, I generally refer to it in the form of a data cache. When the data set is handled, it applies a set of rules. This rule is similar to the default mapping rules used by UpdateGrams and XML Bulk Load when not specified in the mapping outline, and the data set uses this rule to create a data set for storage. A table of mapped XML data. The mapping rules for the data set are summarized as follows: • Composite elements - Elements containing other elements or properties are mapped to tables.
• Simple-Valued Child Elements - Elements that contain only data, not containing other elements or attributes - mapping columns.
• The data type is mapped from the XSD type to .NET type.
Inference is a quick and convenient way to load an XML document into a data set. Tables, columns and relationships are automatically established by "INTROSPECTION", "self-measurement" is the process of the structure and content of the data set check XML document. Although the use of reasoning significantly reduces your programming burden, it also brings unpredictability to your implementation because small changes to XML documents may cause a data set to establish different forms of tables. These forms of changes may cause your application unexpected interrupt. Therefore, I recommend that you generally reference an outline for the application, and limit the use of reasoning when the prototype is established.
Now let's take a look at how to build an example of client dataset data cache that can be used to update the SQL Server database.