Summary of the invention
The present invention be directed to above problem, set up between with the data of XML form and existing database one flexibly, extendible data are quickened and the SQL of the data of XML form and database between the corresponding middleware (XML-Relational Middleware) that concerns, promptly between with the data of XML form and existing database, erect a bridge block.Its purpose is exactly to quicken to handle problems in order to solve among the OSS more and more with data such as frequent retrievals, modification when mutual between the data of XML form and the existing database.
The technical solution adopted for the present invention to solve the technical problems is:
A kind of method that concerns that the middleware expedited data is handled of utilizing is set up a kind of middleware that concerns between query engine module and background data base, this concerns that middleware can be converted into SQL statement with the file of XML form, and inquires about in background data base.
The file of XML form comprises XML dtd file and XML Schema file.
Concern that middleware is converted into SQL statement by mapping relations with the file of XML form and specifically may further comprise the steps:
The file of A, XML form generates the two-dimentional relation table by the metadata management module according to mapping relations, and as the file fractionation of XML form and the foundation of reduction;
The file of B, XML form is converted into SQL statement by described two-dimentional relation table and passes to query processing and draw the attack module.
Concern that middleware comprises an XQuery enquiry module, this module is the syntax parsing of realizing XQuery or XPath query requests, and query requests is converted to the inquiry representation of standard, at last transformation result is passed to query processing and is drawn the attack module.
Query processing is drawn the attack module XQuery enquiry module is translated as SQL statement, and with the structure of query structure according to the metadata management module, the data that are reduced into the XML form are given the user, realize user's transparent inquiry.
The present invention is directed to the applicable cases of existing system, frequent mutual condition between application layer and the background data base is substantially: input is with the condition query of XML form, the output result of inquiry still is with the content of XML form, thereby this patent is in order to solve above-mentioned mode of operation, and just design proposes following several programme of work:
1, according to mapping techniques, with the XML Schema file content of XML form or the order between element, attribute and the element in the XML dtd file content or the like, wherein element, best property of attribute mapping become field or other some compositions in a relation or the relation by mapped mode.
2, with the contents such as concrete element, attribute in the data file of XML form, according to the analysis in 1, resolve into tuple one by one, be saved in the background data base.And the particular type of backstage database and optimisation strategy are ripe and transparent to the user.
3, to the inquiry of the data of XML form, the query translation of these data is become the SQL query of correspondence database, according to the later data set of inquiry in database, the form that is reduced to XML offers the inquiry.
4, the present invention also designs storage policy in its method of work according to such scheme, thereby solve the task in frequent mutual between application layer and the background data base more neatly, its storage policy is: data-centered XML document (for example: the site information of monitoring in the OSS system, warning information etc.) is split, be stored in the corresponding relation table, with the document be the center the XML data (for example: the site information of OSS monitoring etc.) as the access of LOB type.
Illustrate: the memory module of the content of XML form in database can have following three kinds of patterns according to the characteristics of XML data of description:
| Memory module | Advantage | Shortcoming |
| Deposit the corresponding relation table in by the layer of structure fractionation | Mapping is simple, and nearly all relational database is all supported. | After level enlarged, the related complexity between table and the table caused database to carry out decrease in efficiency. |
| As LOB type whole stole only take | Simplified operation greatly, the whole stole only take of Xml has been simplified intermediate conversion. | Practical application kind applied environment is subjected to certain restriction. |
| Deposit database in as data object | Can keep original XML document data structure and associated metadata preferably | Can only store data by the peculiar correlation technique of XML, can only use in certain product, scope is little. |
Wherein, the XML dtd file is converted into the regular as follows of SQL file in the background data base:
Rule 1: if a certain elements A in XML DTD definition is the daughter element of another element B, and the pass of B and A is (0,1) or (1), and not have the daughter element of other element be A, so daughter element is incorporated into his father's element and shines upon in the relation schema that obtains;
Have the element of corresponding related contact one by one among the rule 2:XML DTD,, so both are merged as an element if both participate in this related contact fully; If both sides participate in fully, should be a relation so with the element map of subparticipation, and the related one to one element interpolation external key of getting in touch of participation point to this element fully; Otherwise when being mapped to XML DTD by relation schema, both are mapped as element, and the element that participates in fully will add the IDREF attribute;
Rule 3: in the XML of one-to-many DTD pattern, at first replenish and carry out the merging of part element, then father's element and other daughter element are mapped as master, the sublist of relation schema and set up main external key relation according to rule 1; Setting up a temporary table again is used to store field that all sublists comprise and sets up main, external key with master meter and get in touch; The numerous master who sets up previously, the connection of sublist are eliminated;
Rule 4: for the association contact of the multi-to-multi among the XML DTD, handle, then the relation schema that produces is carried out standardization processing according to rule 1 additional replenishing with rule 3;
Rule 5: by the semantic key that is contained in the XML document, for absolute key, resulting goal set path expression can be used as a concordance list, and set up the set that the table of same structure one to one is used to deposit pairing element under each index according to the index of each, and connect with concordance list, when the data storage with the XML form arrives relation data, enter corresponding relation table according to affiliated different index; For relative key, can set up the notion of multiple index; Principle is set up mode with the index of absolute key;
XML Schema file is converted into the regular as follows of SQL file in the background data base:
The rule 1: with each " attribute " in the XML Schema schema document or
" attributeGrioup " is mapped as the field in the tables of data, and use is " reguired "
The best property of attribute mapping of value is " not null ".
Rule 2: the simple type definitions NE type (NetworkType) of element or attribute is mapped as the CONSTRAINT restriction of a respective field in the tables of data according to concrete condition.For example as following NE type (NetworkType) mapping example:
Rule 3_1: complicated type A comprises a B element of gathering around with complicated type, and this is a man-to-man relation, and this patent design will be created two Table As and B, and restriction relation is for when the example of A is deleted, and the example that is contained in B wherein is also deleted together.
Rule 4_1: complicated type A comprises a plurality of elements that have complicated type C, the element that has complicated type C is included among the complicated type A, other element that has type A can not be shared the daughter element that these types are C, this is the relation of an one-to-many, restriction relation is for when type being the element of A when deleted, and the daughter element that is contained in wherein type and is C is also deleted together.NE type (NetworkType) many-one relationship mapping example in for example following XML pattern:
Rule 3_2: of containing complicated type D of complicated type A quotes, reflection be the many-to-one relation of inter-entity, the mode of operation of this patent design will be created two Table As and D; Table A and table D restriction relation are the cascading delete referential integrity, i.e. all row of wanting deleted Major key to be complementary among its external bond of deletion and the table D from rely on Table A.NE type (NetworkType) many-to-one relationship mapping example in for example following XML pattern:
Rule 4_2: complicated type A contains a plurality of of complicated type E is quoted, what reflect is the relation of the multi-to-multi of inter-entity, and complicated type E must be created between A, so in mapping process, except setting up A, the E off-balancesheet must be created one and connect Table A _ E_Link, restriction relation is for when a tuple among A or the E is deleted, and the relative recording among Table A _ E_Link also should be deleted.NE type (NetworkType) many-to-many relationship mapping example in for example following XML pattern:
The mode of operation of this patent design adopts the guiding tool of XPath as inquiry, and its method is finished exactly between SQL and XPath or the XQuery and changed, and finally realizes the data query interactive task between application layer and the database.Its process is in XML inquiry explanation module, according to XML Schema-〉result of RelationalSchema mapping, with the XPath query statement of input, be converted to corresponding SQL query.Concrete conversion method is;
With the Context of XPath inquiry, be converted to " the from clause " of SQL;
With the path of XPath inquiry, be converted to " the select clause " of SQL;
With the Expression of XPath inquiry, be converted to " the where clause " of SQL.
A kind of method that concerns that the middleware expedited data is handled of utilizing of the present invention, can solve among the OSS more and more with data such as frequent retrievals, modification when mutual between the data of XML form and the existing database and quicken to handle problems, thereby improve the processing power and the efficient of system, reduce the average response time of user inquiring.
Embodiment
Below in conjunction with the drawings and specific embodiments a kind of utilization the of the present invention concerned that the method that the middleware expedited data is handled is further described.
With the field of telecommunications integrated network management system is that example illustrates concrete application of the present invention.
Integrated network management system belongs to an important support platform of field of telecommunications, support each prefecture-level subsidiary company and the various aspects personnel's of province company use, therefore visit capacity also is very big, must cause lot of data processed (retrieval, modification or the like).Wherein the inquiry system treatment step of general form as shown in Figure 1, utilize the present invention on reporting system, use this data speedup query method based on middleware, be revised as query steps as shown in Figure 2, to be forwarded to earlier that data are quickened with the query requests content of XML form and the SQL of the data of XML form and database between corresponding concerning on the middleware (XML-RelationalMiddleware), and draw attack to the querying condition analysis by the query processing of XML-Relational Middleware, data are obtained, processes such as data processing are returned the result set that the user will inquire about again.Thereby improve the processing power and the efficient of system, reduce the average response time of user inquiring.
Embodiment:
The first step: prepare before implementing
When carrying out the design of integrated network management system background data base, can in the table designer of background data base, be the XML type with a Field Definition.(illustrate: the XML field can not be used as major key or index key).Simultaneously, also use SQL statement to create the tables of data of using the XML field, promptly the network element site information table of " A_SITE_INFORMATION " by name created in the statement below, and this watchband has integer major key " id " and non-typed XML row " xCol ":
CREATE?TABLE?A_SITE_INFORMATION(id?INT?PRIMARY?KEY,xCol?XMLnot?null)
The XML type illustrates: owing to except using in table, can also occur in storing process, affairs, function etc.
Second step: realize right XML operation, use the data of an XML type of SQL statement definition, and be its assignment:
Definition XML categorical data
declare@xmlDoc?xml;
set@xmlDoc=’<netype=″site″>
<site_id>001</site_id>
<site_name>JiNan</site_name>
<regionid>C2</regionid>
<city>jinan</city>
.
.
.
</netype>’
The 3rd step: retrieve data operation
After the data that defined an XML type, the most frequently used is exactly query manipulation, just is to use SQL statement to carry out the example of query manipulation below:
SQL illustrates: owing to can provide two functions that the XML categorical data is inquired about, be respectively query (xquery) and value (xquery, dataType), wherein, what query (xquery) obtained is the data that have label, and value (xquery, what dataType) obtain then is the content of label.
Example 1:
When using query (xquery) inquiry, need obtain the site information of Jinan City, use query (xquery) to inquire about, query statement is:
Query () function
select@xmlDoc.query(’/netype/site_id’)
Example 2: (xquery when dataType) inquiring about, need obtain the site information of Jinan City equally, uses the value function, need indicate two parameters, and one is xquery, and another is the type that obtains data to use value.See following query statement:
Value () function
select@xmlDoc.value(’(/netype/site_id)[001]’,’nvarchar(max)’)
Example 3:
Statement during the querying attributes value is:
Querying attributes
select@xmlDoc.value(’(/netype/@s?ite_id)[001]’,’nvarchar(max)’)
Example 4:
When using xpath to inquire about, can obtain the node wanted easily, and need not use the where statement.In the following search method, added the another one node among the Zai @xmlDoc, promptly redefine into:
The xpath inquiry
set@xmlDoc=’<netype>
<netype=″site″>
<site_id>001</site_id>
<site_name>JiNan</site_name>
<regionid>C2</regionid>
<city>jinan</city>
.
.
.
</netype>
<netype=″bsc″>
<bsc_id>002</bsc_id>
<bsc_name>JiNan</bsc_name>
<region>C2</region>
.
.
.
</netype>
Obtaining netype for the statement of the network element nodal information of " bsc " is:
select@xmlDoc.query(’(/netype[@netype=″bsc″])’)
At last, the final query result data are returned to upper layer application, carry out report form showing, feed back to the user, processing finishes.
In sum, corresponding middleware (XML-Relational Middleware) and the data speedup query method of concerning is applicable to the situation at a large amount of query requests between the SQL based on the data of XML form and database.Also can be widely used in other industry fields such as (as telecommunications, finance), have certain use value.
Above-described embodiment, the present invention embodiment a kind of more preferably just, the common variation that those skilled in the art carries out in the technical solution of the present invention scope and replacing all should be included in protection scope of the present invention.