Save a large number of XML documents in relational databases

xiaoxiao2021-03-05  22

When saving an XML document in a relational database, you must have encountered a lot of problems due to a large number of documents, especially for a large number of documents. This article will propose specific issues related to a large number of XML documents, and then give a method of solving these problems.

Potential problem with very large document

What is the XML document becomes very huge? One of an XML document has become a huge sign is that there is a problem when the document is started. Now let us discuss the potential problems.

The first is the viewpoint of Raw Space. The problem occurs and the frequency and space. Not your document is greater than usual, but you frequently use them frequently. You must have a good size data partition to store these documents (or databases).

Second, running a database may generate an error. Sometimes the XML document is divided into multiple parts and stores in a discontinuous table representing the XML document structure, but usually, the XML document is stored in the BLOB domain, text domain, or VARCHAR domain.

In addition to the deficient in design, you may also encounter problems on the interface that communicates with the database. For example, most SQL execution limits data to 4,096 bytes - this means that when you use SQL to send 10KB documents to the database, you will be obstacted. A similar limit is also present in the database store program. If you don't realize these restrictions, you will encounter these issues.

Database Design

Developers and database managers must clearly understand the operations that will be generated in XML documents, so it is possible to design the database correctly. It is also quite important to understand how the database will be used. Your XML document is a simple continuous storage mechanism? Or is it stored in a discontinuous state?

If you store the entire document in whole, you have a variety of options. For discontinuous data, you should design a table representing an XML structure and store the data in a separate table. The advantage of the second step is that the canxicity and inquiry, and you don't need to operate the entire document.

BLOB (binary large object) domain is used to store data of large binary formats. For example, an encrypted file is often used in a BLOB domain. The BLOB domain is ideal for storing XML files. The disadvantage of the BLOB domain is that it is not a comparable and queries, and the large amount of data cannot be exchanged by standard SQL and BLOB.

segmentation

One way to solve SQL restrictions is to split XML documents into blocks of 4KB or small. These small pieces are stored in the table and then linked these small pieces using the ID domain.

When you store these documents, you should split them into small pieces and store them in the table. When you return a document, you select all blocks through a specific ID, and then you will collect them in a suitable order. Although it is more trouble, this method is very useful for multi-database.

Bundle and BLOB Access

The problem with large BLOB data is that you cannot store and get data. In recent years, each database merchant has had its own way of storage and obtaining large objects.

To store a large number of XML documents in a blob domain, you have to use binding. Bundle is the process of interconnecting data from program code from domains in the database. Using this method, when changing the database, there may be other features that can affect the database.

to sum up

Storing a large number of XML documents in a relational database will result in many problems. Solving the primary steps of these issues are deep understanding of the parameters in the XML document. The appropriate solution is then properly designed. The solution can include: a series of structural tables, split the XML document into small pieces, or ties directly to the BLOB domain in the database.

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

New Post(0)