XML and database

xiaoxiao2021-03-06  65

Author: Unknown

Directory 1.0 Introduction 2.0 XML is a database? 3.0 Why use Database? 4.0 Data and File 4.1 Data-centric Document 4.2 Taking Document Centered Document 4.3 Data, Document and Database 5.0 Data Acquisition 5.1 Map Document Schema to Database SCHEMA 5.1.1 Based on Form Based on Form 5.1 .2 Relationship - Object Mapping 5.2 Query Language 5.2.1 Template-based query language 5.2.2 SQL-based query language 5.2.3 XML Query Language 5.3 In the native XML database stores data 5.4 data type, NULL value, character set, and Other 5.4.1 Data Type 5.4.2 Binary Data 5.4.3 NULL Data 5.4.4 Character Set 5.4.5 Processing Instructions and Note 5.4 Tag Storage 5.5 Relationship [Database] Schema Generates DTD and the Converse 6.0 file 6.1 Storage file 6.2 In Blob 6.3 Native XML Database 6.3.1 What is a native XML database? 6.3.2 Native XML database architecture 6.3.2.1 Based on text-based native XML database 6.3.2.2 Based on model-based native XML Database 6.3.3 Native XML Database Features 6.3.3.1 File Set 6.3.3.2 Query Language 6.3.3.3 Update and Delete 6.3.3.3.3.3.5 Application Interface (APIS) 6.3.3.6 Double Channel Tickets 6.3.3.7 External Data 6.3.3.8 Index 6.3.3.9 External entity Storage 6.3.4 Standardization, reference integrity and scalability 6.3.4.1 Standardization 6.3.4.2 Reference Integrity 6.3.4.3 Scalability 6.3 Sustainable DOM (PDOM 6.4 Content Management System 7.0 XML Database Products 8.0 Related Links 9.0 Opinions and Feedback 1.0 Introduction This article describes how to use XML and databases, describe the data as The difference in the center and documentation in the documentation affects the general usage of the application, XML and relational databases in the database, and what is the native XML database and when it is used. 2.0 XML is a database? (IS XML A DATABASE?) Before you start discussing XML and database, we first answer the questions that many people mentioned: "Is XML is a database?" If you press only the nature of this term, the XML file is a database. That is, it is a collection of data. It doesn't seem to differ from many aspects that it is nothing differences - anyway, each file contains some type of data. As a "database" format, XML has some advantages: for example, it is self-description (the lack of the data describes the structure and type of the data, despite the lack of semantic), the portable (Unicode), can be treated Type or graphic structure describes data. Similarly, it also has a disadvantage, for example, it is redundant, since it is parsed and text conversion, the data accesses is slow. A more useful problem is whether XML and its peripheral techniques can be counted as "database" - ie database management system (DBMS). The answer is "sort of)".

From the front, XML provides a lot of data (XML documents), mode (DTD, XML Schema language), query language (XQuery, Xpath, XQL, XML-QL, Quilt, etc.), programming interface (SAX, DOM, JDOM), etc. From the reverse, it lacks some real databases should have: Efficient storage, indexing, security, transaction and data consistency, multi-user access, trigger, query in multiple files, etc. XML is suitable for use as a good example of the so-called "database" is .ini file - it contains configuration information for the application. With a parser that handles files with comma-delimited files, develop a small XML language and write a way to explain its SAX program. In addition, XML allows the use of nested entities, and comma-delimited files is difficult to do. However, it is said that it is still boring because it is linearly read and written, and is only used in the start and end of the program. Some complex datasets suitable for XML databases are personal address books (name, phone number, address, etc.), or to describe browser bookmarks and MP3 stolen with NAPSTER. However, because DBASE and Access are affordable, even if there is no reason if there is no reason to use the XML file as a database. The only real advantage of XML is the portable, because more and more tools can be used to access the database as XML, this benefit seems to have some discount. 3.0 Why use the database? (Why USE A DATABASE?) When you start considering the XML and the database, you must first answer this question: Why do you want to use the database first? Do you want to use existing data? Do you want to find a place to store web pages? Do you use a database in e-commerce, and XML acts as a data transmission carrier? The answer to these issues will greatly affect the choice of your database and middleware (if any) And how to use the database. For example, you have an e-commerce application to use XML as a data exchange. Then your data is preferably a height-regulated structure and is used by non-XML programs. Also, some things used by XML documents are not important to you, such as entities and codes. In short, you are interested in data instead of how it is stored in XML. In this case, you probably need a relational database and software that converts data between XML and databases. If your application is an object-oriented, you don't even need a system that allows these objects in the database or XML. On the other hand, if you want to create a website from some xml documents facing the prose-oriented. You must not only manage this website, but also provide a way to let users find content. Your document looks loose structure, the use of entities may be more important to you because they are an important part of the document structure. In this case, you may need a native XML database (Native XML Database) or Content Management System. This allows you to keep the physical structure of the document, support the file level transaction processing, and query using the XML Query language. 4.0 Data and Documents (Data Versus Documents) The most important factor when choosing a database is probably what you want to store data in the database or document.

For example, it is simply as a data conversion tool between the database and (may not support XML) applications, or is it used to integrate, just like XHTML and DOCBOOK? This is usually a preference, but it is very important because all of the same characteristics in data-centric documents, all of which have many Document-centrics. This will affect how XML is stored in the database. In the following two parts, we will visit these features. (Historical Background: I first heard of Data-Centric and Document-Centric on the XML-DEV mailing list, I don't know who is invented, but I found Document-Centric in 1997, from These two terms have been used in 1998.) 4.1 Data-centric documents (data-centric documents) Central document is data-centric documentation is the transmission carrier for data as data, which is specifically provided to machine consumption, there is no need All use XML. That is, for the application or database, the data is stored in the form of an XML document in a certain period of time. Examples of documents centered on data have sales orders, flight schedules, scientific research data and stock market exchange rates. The data-centric document is characterized by quite normal, fine-grained data (i.e., the smallest independent data unit exists only at the PCDATA element or attribute level), rarely or has no mixed content. Unless verified by the document, the order of the appearance of the same level or PCDATA is generally not important. Such data in data-centered documents can be from the database (to XML at this point) or outside the database (now you want to deposit it into the database). An example of the former is a large amount of data in the existing database; the research data from the measurement system is collected and converted to XML is an example of the latter. For example, the following sales order is based on data:

ABC Industries

123 main st.

chicago

Il

60609

981215

Turkey Wrench:

Stainless Steel, One-Piece Construction,

Lifetime Guarance.

9.95

10

stuffing separator:

Aluminum, One-Year Guarantee.

13.27

5

In addition to this obvious data-centric document, many item-based documents may be data-based except for the marketing order. For example, Amazon.com is used to display a page of book information. Although most of the content on the page is text, the structure of these text is very rule, many of them are the same as other books, and there are not many texts that are unique to each page. In this way, the relevant information of books can be taken from the database, converted to simple, data-centered XML documents, and then generate a page with the XSL style table. In general, those websites that use data in the database, dynamically generate HTML files can turn to use a series of data-centric XML documents and XSL style sheets. For example, the following is a document describing flight information:

Abc Airways provides three

Non-Stop Flights Daily from Dallas To

Fort Worth . Department Times Are

09:15 , 11:15 ,

And 13:15 . Arrival Times Are Minutes Later.

Create this document from the XML file below and a simple style sheet:

abc airways

Dallas

Fort Worth

09:15

09:16

11:15

11:16

13:15

13:16

4.2 Document-centric documents (Document-Centric Documents) is usually for consumption. For example, books, email, advertising, and almost all artificial XHTML files. Its characteristics are structurally unsteady or irregular, and the data particle size (the minimum independent data unit may exist in the elements of the mixed content or even the entire document itself), and the mixed content is more. The order of the appearance of the same level or PCDATA is generally always very important. The documentation-centered documentation is usually written in XML or converted from other formats (such as RTF, PDF, SGML) to XML, which is often not derived from the database. (The document obtained by the data inserted into the template is data-centric; more information, see the end of the 4.1 section). Conversion of various formats into XML software information, see XML software related links. For example, the product below is based on documentation:

The Turkey Wrench from FULL

Fabrication Labs, Inc. is

Like a monkey wrench,

But not as big.

The Turkey Wrench, Which Comes in Both Right- and Left-

Handed Versions (Skyhook Optional) , IS Made of the Finest

Stainless Steel . The Readi-Grip Rubberized Handle Quickly Adapts

To Your Hands, Even in The Greasiest Situations. Adjustment IS

Possible Through a Variety of Custom Dials.

you can:

Order Your Own Turkey Wrench

Read more about wrenches

Download The Catalog

The Turkey Wrench COSTS JUST $ 19.99 and, if you

Order Now, Comes With a Hand-Crafted Shrimp Hammer as a

Bonus gift.

4.3 Data, documentation, and database (Data, Documents, And Databases) In fact, the difference between data-centered and document-centered documents is not necessarily obvious. For example, another document, such as an invoice, may contain large particle size, non-structured data such as part instructions; another document such as a document such as a user manual, may contain fine-grained structural rules. Data (usually metadata) such as the author and revision date. Other examples include legal and medical instruments, although written in the form of prose but contain discrete data blocks such as date, name, and operation procedures, for statutory reasons, it is usually stored in a complete file form. In addition, the two characteristics of clarifying documents help to select the type of database. In general, the data is stored in a conventional database, such as a relational, an object-oriented or hierarchical database. This can be completed by the third party's middleware or by the database itself provides intrinsic support. For the latter, the database is called XML-enabled. Documents can be stored in native XML databases (database designed for storage XML) or content management system (built in the native XML database specifically used to manage documents). These principles are not absolute. If the features that are unique to XML do not value, data, especially semi-structured data can be stored in the native XML database, and the document can also be stored in the traditional database. What is the boundary between traditional databases and native XML databases is getting more and more blurred, and the traditional database has increased the ability of native XML, and the native XML database adds support for document storage in the external (usual relational) database. The remaining parts of this article discussions with the strategic and reading of data (Section 5) and documentation (Section 6). For the latest XML database products, please see XML Database Products. 5.0 STORING AND RETRIEVING DATA In order to exchange data between XML files and databases, it is necessary to map Schema (DTD, XML Schema, RELAX NG, etc.) of the XML file to the database of Schema. Software for data conversion is built on this mapping. The software can use XML Query language (such as XPath, XQuery, or other dedicated language) or simply convert data in accordance with the mapping (Select * from Table XML peer). For the latter, the structure of the document must fully comply with the structure required by the mapping. Since it is usually not easy to do, products using this strategy are usually used with XSLT. Before the data is switched to the database, the file will be converted according to the structure required by the mapping, and then the data is transferred. Accordingly, after the data is removed from the database, the result file is converted to the structure required for the application. 5.1 Mapping [XML] Files Schema to Database Schema (Mapping Document Schemas To Database Schemas) File Schema to Database Schema's mapping is made on element type, attribute, and text. Almost always ignore physical structures (such as entities, CDATA) and certain logical structures (such as handling instructions, annotations, and sequential sequentials that appear in parent elements). This is more reasonable than it, because the database and application simply cares about the data in the XML file. For example, in the above-mentioned sales order, the customer code is in the CDATA portion, or the external entity is not important, and the customer code has nothing to do before or after the order date. One consequence of this method is whether the document has a "round-trip ticket" - after depositing the data in the file, the data from the data in the database, and this file is often different from the original file (even from the most In general, in general). Is the software to consider whether it is allowed to occur.

There are two ways to map the Schema of an XML file to the database. There are two ways: table-based mapping and object-relational mapping. 5.1.1 Table-based mapping Many intermediate software for converting XMLs to the database adopts a table-based mapping. It treats XML files as a (or a group) table, that is, the structure of the XML file must be the following look, if only a single table, no longer need the element and other

elements:

...

...

...

...

...

...

...

Depending on the software used, you can specify that the field data is stored as child elements or attributes, or the name of these elements or properties can be specified. In addition, the use of a table mapping method may also allow metadata of the table or various fields to be started at the beginning of the file, or the properties of each table or element. Note that "Table" mentioned here is the form of a general referral. When data is transferred from the database to the XML file, the "Table" can be any result set, in turn, "Table" can be a normal form or an updated view. Table-based mapping is compared to access relationship data, such as conversion data between two relational databases. It is obvious that it is not suitable for XML files that do not match the above format. 5.1.2 Object - Object-Relational Mapping All Support XML relational databases and certain middleware can use object-relations mapping methods. It treats data in the XML file as a model of a specific object tree. In this model, the elements and their types, elements or mixed content (composite element types) are often considered class. Elements (simple element types), attributes, properties, and PCDATA have been used as simple properties. The model is then mapped to the relational database through a traditional object-relational mapping technology or SQL 3 object view. That is, the class is mapped to the table, and the simple attribute is mapped to the field, and the value is the primary key / foreign key that the object property is mapped to pair. (The so-called "object-relational mapping" actually name is not true. Because the object tree can be directly mapped to an object-oriented and hierarchical database, however, because most of the mainstream products used by most use of this mapping method are actually a relational database, Therefore, "Object-Relational Mapping" is also widely known.) We must know when understanding the object model used in this mapping, this object model is not a file object model (DOM). All the DOM of all XML files is the same, and the model of the above description file data is different for each DTD defined XML file, for example, the model of the above-mentioned sales order is an object tree composed of four classes - SalesOrder, Customer, Item, and Part, as shown below: SalesOrder

/ | /

Customer Item Item

| | |

Part part

In the DOM generated by the same file, the composition of the object tree is element, attribute, and text: element --- attribute

SalesOrder (Sonumber)

____ / / / / / _____

/ / / /

Element Text Element Element (OrderDate) (item) (Item)

| | | | |

ETC. ETC. ETC.

Whether the object in the model is instantiated to depends on the software used. Some software allows you to generate classes based on the model, and then you can use the objects generated by these classes in the program. In these products, the data is passed between XML file-object-database. Other products are data conversion directly between XML files and databases, and objects are just visual assistance tools for this process. It is useful to generate these intermediate objects to depends entirely on your application. (According to Sun's Java Architecture for XML Binding, XML files and object bindings are often referred to as XML Data Bindings, some products support XML data bindings, many of which can also be done between objects and databases Data exchange, more information, see XML Data Binding Related Resources XML Data Binding Resources.) Various product support objects - the specific implementation methods of relational mapping are different. E.g:

All products support mapping from the composite element type to classes, and from simple element type and attribute (attributes) to [class] properties (Properties). Almost all products allow you to specify that the root element is not mapped to an object model or database. This packaging element is useful if you want to store multiple top objects in the same XML document. For example, if you want to store multiple sales orders in the same XML file, you must pack them within a root element. This packaging element is equivalent to the element when using a table-based mapped XML file, this packaging element is equivalent to the element because the XML file can only have one root element based on the current standard. A small number of products allow you to specify packaging elements at a lower level. Most products allow you to illustrate the properties of the [Object "property (Properties) to the attribute (Attribute) or child elements. Some products also allow you to mix the properties and child elements, others only allow you to use one of them. Most products allow the XML file and the name of the database to be different. A small number of product requirements must use the same name. Most products allow you to explain the order of the child elements in the parent element, nevertheless, it is still impossible to build multiple content models. Fortunately, for most data-centric documents, the content model provided is sufficient. (When the file needs to be verified, the order of the child elements is quite important.) Some products allow you to map the composite element type to the profment property. This is quite useful when an element contains mixed content (such as element in the sales order). Although element contains sub-elements and text like XHTML, it is best to treat this Description as a single attribute instead of dividing it into many pieces. There are not many products that support PCDATA mapping in mixed content. For a detailed description of the object-relational map, please see the third part "map DTD to the database". 5.2 Query Languages ​​Many products are exchanged directly according to their models they build. Since the structure of the XML file and the structure of the database are generally different, these products generally use or include XSLT style sheets. This allows the user to convert files based on the format specified by the model before data is swapped to the database. Some products are only available for limited several such conversions due to the high cost of XSLT processing. The long-term solution for this problem is to design a query language that can return XML [file]. Currently, in February 2002), most of this language is embedded in the SELECT statement in the template. When the XQuery finalized, this situation is expected to change, as the mainstream database product provider has done. Unfortunately, almost all XML query languages ​​(including xQuery1.0) can only read data, so the current most needed is to insert, update, and delete data. (From the long run, XQuery will add this feature.) 5.2.1 Template-based query (Template-based query) Most of the query language read XML from the database is template, these languages ​​do not predefine XML The mapping between files and databases, is the opposite, is embedded in the template and processes the results of the data exchange software. For example, the following template (not true product) uses the element containing the SELECT statement and the $ column-name value to set the result.

The Following Flights Have Available Seats:

SELECT Airline, FltNumber, Depart, Arrive from Flights

$ airline

$ fltnumber

$ depart

$ arive

We Hope One of these Meets Your Needs

The results after this template process may be:

The Following Flights Have Available Seats:

ACME

123

DEC 12, 1998 13:43

DEC 13, 1998 01:21

...

We Hope One of these Meets Your Needs.

Template-based query language can be very flexible. Although the functions of each product are endless, there are some common features:

转载请注明原文地址:https://www.9cbs.com/read-90668.html

New Post(0)
CopyRight © 2020 All Rights Reserved
Processed: 0.044, SQL: 9