An Object-Relation SQL Mapping Method for Object Query

By acquiring all databases in the object-relational SQL mapping method of object query, analyzing and mapping processing query keywords and historical query information, selecting the database with the fastest data processing speed for query, the problem of single data sources and slow query speed in the existing technology is solved, and efficient query processing and system operation speed is achieved.

CN119003568BActive Publication Date: 2025-03-04ZHEJIANG MAI XIN TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411475312.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-22
Publication Date
2025-03-04
Estimated Expiration
2044-10-22

AI Technical Summary

Technical Problem

The existing object-relational SQL mapping method used for object queries cannot determine whether the data in the database needs to be called based on historical query information, and cannot be converted to other databases for querying, resulting in a single data source and slow query speed, and it is impossible to ensure that no secondary query is required for each query, resulting in slow processing speed during overall system operation.

Method used

By obtaining all databases, performing library analysis and mapping processing, extracting query keywords and historical query information, and determining whether there is a historical query situation. If there is, the most suitable query results will be obtained using the historical query results as the benchmark. If there is no, the query results will be obtained using the keywords corresponding to the query information as the benchmark, and the database with the fastest data processing speed will be selected for querying.

Benefits of technology

It realizes judging query results based on historical query information and query keywords, avoiding information extraction in a large amount of data in the database for each query, improving query speed, improving the processing speed during the overall operation of the system, ensuring sufficient data sources, and reducing the situation where queries cannot be found.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119003568B_ABST
    Figure CN119003568B_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of data processing, and discloses an object-relation SQL mapping method applied to object query, comprising: obtaining all databases, respectively obtaining query data of each database, forming corresponding mapping data, obtaining target query information, forming extraction data, forming query analysis data, forming determination data, and extracting query content. The object-relation SQL mapping method applied to object query has multiple databases, judges whether it is necessary to call data in the database according to historical query information, converts the data to be queried to other databases for query, selects the database with the fastest data processing speed when the system converts the database, has sufficient data sources, reduces the situation where no results can be found, avoids extracting information from a large amount of data in the database for each query, improves the query speed, and thus improves the processing speed of the overall system during operation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data processing, in particular to an object relation SQL mapping method applied to object query. Background Art

[0002] Object-relational mapping (ORM) is a technology developed to solve the mismatch between object-oriented programming (OOP) language and relational database management system (RDBMS). Before ORM, developers usually wrote SQL statements manually and encapsulated them into methods using data access layer (DAL). In order to deal with the "object-relational impedance mismatch" problem, object-relational mapping (ORM) technology emerged.

[0003] "Object-relational impedance mismatch" is mainly reflected in data types, inheritance and polymorphism, and complex object graphs. For example, complex types in objects (such as List and Map) do not match simple types in the database (such as integers and strings). The inheritance and polymorphism features in OOP are difficult to implement directly in relational databases. Complex relationships between objects need to be expressed through multiple tables and foreign keys in relational databases.

[0004] In addition, using SQL directly presents certain challenges. Writing and maintaining a large number of SQL statements is tedious and error-prone. Different database systems support different SQL dialects, making code difficult to port. Manually optimizing SQL queries to achieve optimal performance requires deep database knowledge.

[0005] The object-relational mapping (ORM) method improves development efficiency, reduces maintenance costs, and improves portability. Developers can directly use objects to perform data operations, reducing the time of writing SQL. The code is more intuitive and easy to maintain and modify. The ORM framework usually supports multiple databases, which facilitates system migration and expansion. It is an effective means to solve the impedance mismatch between object-oriented programming and relational databases. With the evolution of technology, the ORM framework is constantly improving, providing a higher level of abstraction and more powerful functions, allowing developers to perform object queries and database operations more efficiently.

[0006] The existing object-relationship SQL mapping method applied to object query has a single database and cannot determine whether it is necessary to call the data in the database based on historical query information. It cannot convert the data to be queried to other databases for query according to the data to be queried. It cannot select the database with the fastest data processing speed when the system converts the database according to the data to be queried. This makes the data source single and insufficient, and it is easy to find no results. The query speed is slow. Each query requires information extraction from a large amount of data in the database, and there is no guarantee that a secondary query is not required for each query, resulting in slow processing speed during the overall operation of the system. Its practicality has certain limitations. Summary of the invention

[0007] The present invention provides an object relation SQL mapping method applied to object query, which is used to promote the solution of the problems mentioned in the background technology.

[0008] The present invention provides the following technical solution: an object-relation SQL mapping method applied to object query, comprising:

[0009] Acquire all databases, where the databases include a first database, a second database, and a third database;

[0010] Identify each database as a target database in turn, obtain query data from each database through database analysis strategy, execute mapping processing strategy on the target database, and form corresponding mapping data;

[0011] Obtain target query information and form extracted data through data extraction strategies;

[0012] Acquire a query keyword set and historical query information, wherein the historical query information includes historical query statements and a historical keyword set corresponding to each historical query statement;

[0013] The historical keyword set containing the same keywords as the query keyword set is defined as the historical extraction set;

[0014] If there is a historical extraction set in the historical query information, it is determined to be the first historical data, and the first analysis strategy is executed to form query analysis data;

[0015] If there is no historical extraction set in the historical query information, it is determined to be the second historical data, and the second analysis strategy is executed to form query analysis data;

[0016] According to the mapping data, extraction data, query and analysis data, the judgment data is formed through the data judgment strategy;

[0017] Based on mapping data, extracting data, querying and analyzing data, and judging data, integrated data is formed and query content is extracted through data integration strategies.

[0018] As an optional solution of the object-relation SQL mapping method applied to object query of the present invention, the library analysis strategy is specifically:

[0019] Get the target database;

[0020] Extract all keywords in the target database to form a keyword set;

[0021] Identify each keyword in the keyword set as a target keyword in turn;

[0022] Extract all query data containing the target keyword in the target database to form a query set for the target keyword.

[0023] As an optional solution of the object-relationship SQL mapping method applied to object query of the present invention, the mapping processing strategy is specifically as follows:

[0024] Get the target database;

[0025] Recognize the databases other than the target database as the first mapping database and the second mapping database respectively;

[0026] sequentially identifying the first mapping database and the second mapping database as target mapping databases;

[0027] Obtain a keyword set of the target database;

[0028] Identify each keyword in the keyword set as a target keyword in turn;

[0029] Obtaining programming data corresponding to the target keyword in the target database as first programming data;

[0030] Obtaining programming data corresponding to the target keyword in the target mapping database as second programming data;

[0031] Acquire the number of conversion steps for converting the first programming data into the second programming data and the data processing speed when converting the programming data;

[0032] Calculate the conversion time of converting the first programming data into the second programming data, where the conversion time=the number of conversion steps×the data processing speed;

[0033] All conversion durations are matched one by one with each keyword in the keyword set to form a word conversion set.

[0034] As an optional solution of the object-relation SQL mapping method applied to object query of the present invention, the data extraction strategy is specifically:

[0035] Obtain target query information;

[0036] Extract all keywords in the target query information, define them as query keywords, and form a query keyword set;

[0037] Obtain a query set corresponding to the first database and define it as a main query set;

[0038] Sequentially extract the query set corresponding to each query keyword in the query keyword set in the main query set, and define it as the extracted query set;

[0039] All extraction query sets are matched one by one with the query keyword sets and integrated into a query extraction set.

[0040] As an optional solution of the object-relationship SQL mapping method applied to object query of the present invention, wherein: the first analysis strategy is specifically:

[0041] S1. Obtain a query keyword set and all historical extraction sets;

[0042] S2, defining a keyword that exists in both the query keyword set and the historical extraction set as the first extraction keyword;

[0043] S3, obtaining the number of historical extraction sets corresponding to each first extraction keyword, and setting it as the number of sets;

[0044] S4. If the number of sets corresponding to all first extracted keywords is the same, execute A1-A3;

[0045] A1. Obtain the number of first extracted keywords contained in each historical extraction set, and define it as the overlap number;

[0046] The historical extraction set with the largest number of overlaps is determined as the priority extraction set;

[0047] Acquire historical query information, where the historical query information includes query results corresponding to each historical query statement in the first database;

[0048] A2. If the number of priority extraction sets = 1, execute B1-B2;

[0049] B1. Extract the historical query statements corresponding to the priority extraction set and set them as the priority extraction statements;

[0050] B2. Extract the query results corresponding to the priority data and set them as the target query results;

[0051] A3. If the number of priority extraction sets is ≠ 1, execute C1-C4;

[0052] C1. Extract the historical query statements corresponding to each priority extraction set and set them as priority analysis statements;

[0053] C2. If all the priority analysis statements are the same statement, the query result corresponding to the statement is extracted and determined as the target query result;

[0054] C3. If all the priority analysis statements are different statements, obtain the historical query time of each priority analysis statement;

[0055] Get the current time;

[0056] Calculate the interval time, interval time = current time - historical query time;

[0057] Extract the query result corresponding to the priority analysis statement corresponding to the interval duration with the smallest value and set it as the target query result;

[0058] C4. If there are priority analysis statements that are different statements, obtain the number of priority extraction sets corresponding to each priority analysis statement, and set it as the number of statements;

[0059] The query results corresponding to the statements with the largest number of extracted statements are analyzed first and are set as the target query results;

[0060] S5. If the number of sets corresponding to the first extracted keyword is inconsistent, execute steps D1-D3.

[0061] As an optional solution of the object-relationship SQL mapping method applied to object query of the present invention, wherein: the steps D1-D3 are specifically:

[0062] D1. Obtain the first extracted keyword with the largest number of sets and set it as the priority extracted keyword;

[0063] D2. If the number of keywords to be extracted first = 1, execute E1-E4;

[0064] E1. Extract all historical query sentences corresponding to the priority extracted keywords and define them as historical words and sentences;

[0065] E2. If all historical words and sentences are the same sentence, the query result corresponding to the historical words and sentences is extracted and determined as the target query result;

[0066] E3. If all historical words and sentences are different sentences, obtain the historical query time of each historical word and sentence;

[0067] Get the current time;

[0068] Calculate the interval time, interval time = current time - historical query time;

[0069] Extract the query result corresponding to the historical phrase corresponding to the interval time with the smallest value, and set it as the target query result;

[0070] E4. If there are historical words and sentences that are different sentences, the number of first extracted keywords corresponding to each historical word and sentence is obtained, which is defined as the number of overlapping words;

[0071] Extract the query results corresponding to the historical words and sentences with the largest number of overlapping words and set them as the target query results;

[0072] D3. If the number of the priority extracted keywords is ≠ 1, execute F1-F4;

[0073] F1. Extract all historical query sentences corresponding to each priority keyword and set them as preferred sentences;

[0074] F2. If all the preferred words and phrases are the same sentence, the query result corresponding to the preferred word and phrase is extracted and determined as the target query result;

[0075] F3. If all the preferred words and sentences are different sentences, obtain the historical query time of each preferred word and sentence;

[0076] Get the current time;

[0077] Calculate the interval time, interval time = current time - historical query time;

[0078] Extract the query result corresponding to the interval duration with the smallest value and set it as the target query result;

[0079] F4. If there are preferred words and phrases that are different sentences, the number of first extracted keywords corresponding to each preferred word and phrase is obtained, which is determined as the number of extracted words;

[0080] The query result corresponding to the preferred phrase with the largest number of words is extracted and determined as the target query result.

[0081] As an optional solution of the object-relation SQL mapping method applied to object query of the present invention, the second analysis strategy is specifically:

[0082] Obtain a query keyword set and a query extraction set;

[0083] Extracting query data corresponding to each keyword in the query keyword set in the query extraction set, and defining it as query analysis data;

[0084] Extract the number of each query analysis data in the query extraction set and define it as the query score number;

[0085] The query analysis data corresponding to the query score quantity with the largest value is determined as the priority query data;

[0086] Get the number of priority query data, which is defined as the priority query number;

[0087] If the number of priority queries = 1, the priority query data is set as the target query data;

[0088] Obtaining a query result corresponding to the target query data in the first database, and defining it as the target query result;

[0089] If the number of priority queries ≠ 1, obtain the storage data of each priority query data;

[0090] Get the current time;

[0091] Calculate the storage duration of each priority query data, storage duration = current time - storage data;

[0092] Extract the priority query data corresponding to the storage duration with the smallest value and set it as the target query data;

[0093] The query result corresponding to the target query data in the first database is obtained and is defined as the target query result.

[0094] As an optional solution of the object-relation SQL mapping method applied to object query of the present invention, the data determination strategy is specifically as follows:

[0095] Get the target query results;

[0096] Obtain word conversion sets of the second database and the third database respectively, and define them as a first conversion set and a second conversion set respectively;

[0097] Extract all keywords of the target query results and define them as result keywords;

[0098] Obtain the conversion duration corresponding to each result keyword in the first conversion set, and set it as the first duration;

[0099] Obtain the conversion duration corresponding to each result keyword in the second conversion set, and set it as the second duration;

[0100] Calculate the first conversion duration, where the first conversion duration = the sum of all first durations;

[0101] Calculate the second conversion duration, the second conversion duration = the sum of all second durations;

[0102] If the first conversion time is greater than the second conversion time, the third database is identified as the conversion database;

[0103] If the first conversion time is less than the second conversion time, the second database is identified as the conversion database;

[0104] If the first conversion time length = the second conversion time length, the number of database data in the second database and the third database are obtained respectively, and are set as the first database number and the second database number respectively;

[0105] If the number of the first database is greater than the number of the second database, the second database is identified as the conversion database;

[0106] If the quantity of the first database is less than the quantity of the second database, the third database is identified as the conversion database;

[0107] If the number of the first database = the number of the second database, then the second database or the third database is arbitrarily extracted and identified as the conversion database.

[0108] As an optional solution of the object-relation SQL mapping method applied to object query of the present invention, the data integration strategy is specifically:

[0109] Get the target query results;

[0110] Obtaining a determination result of the target query result, wherein the determination result includes correct and incorrect;

[0111] If the determination result of the target query result is correct, the target query result is used, and the target query result is updated and stored in the historical query information;

[0112] If the determination result of the target query result is an error, the conversion database and all result keywords are obtained;

[0113] Extract the query data containing all the result keywords in the conversion database and define them as the secondary query results;

[0114] Obtaining the determination result of the secondary query result;

[0115] If the determination result of the secondary query result is correct, the secondary query result is used, and the secondary query result is updated and stored in the historical query information;

[0116] If the determination result of the secondary query result is an error, the remaining database is obtained;

[0117] Extract the query data containing all the result keywords in the remaining database and define them as multiple query results;

[0118] Obtain the determination results of multiple query results;

[0119] If the judgment results of multiple query results are correct, the multiple query results are used, and the multiple query results are updated and stored in the historical query information;

[0120] If the judgment result of multiple query results is wrong, then obtain the query keyword set;

[0121] Extracting all query data containing elements of the query keyword set from the first database, the second database, and the third database to form a complete query set;

[0122] The elements in the complete query set are identified as selection query results in sequence, and the determination results of the selection query results are obtained until the determination results are correct;

[0123] The use result is determined to be a correct selection query result, and the selection query result is updated and stored in the historical query information.

[0124] The present invention has the following beneficial effects:

[0125] 1. The object-relation SQL mapping method applied to object query extracts keywords from query information and obtains all historical query information to determine whether the query information has historical query information. If there is a historical query, the most appropriate query result is obtained based on the result of the historical query, avoiding information extraction from a large amount of data in the database for each query, thereby improving the query speed and thus improving the processing speed of the overall system during operation.

[0126] 2. The object-relationship SQL mapping method applied to object query extracts keywords from query information and obtains all historical query information to determine whether there is a historical query in the query information. If there is no historical query, the keywords corresponding to the query information are used as a benchmark to obtain the most appropriate query results, thereby improving the query speed and thus improving the processing speed of the overall system during operation.

[0127] 3. The object-relationship SQL mapping method applied to object query extracts keywords from query information, obtains query analysis data, determines the statements that need to be queried, selects the database with the fastest data processing speed when the system converts the database, and converts the database for query. The data source is sufficient, the situation where no results are found is reduced, and information extraction from a large amount of data in the database is avoided for each query, thereby improving the query speed and thus improving the processing speed of the overall system during operation. BRIEF DESCRIPTION OF THE DRAWINGS

[0128] Figure 1 The present invention is a flow chart of the object-relationship SQL mapping method applied to object query. DETAILED DESCRIPTION

[0129] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0130] Embodiment 1, an object relation SQL mapping method applied to object query, see Figure 1 ,include:

[0131] Acquire all databases, the databases including a first database, a second database and a third database, wherein the first database is a database using SQL, and the second database and the third database are databases using other programming languages, such as HQL and JPQL;

[0132] Identify each database as a target database in turn, obtain query data of each database respectively through the database analysis strategy, execute the mapping processing strategy on the target database, and form corresponding mapping data, wherein the query data is the number of steps corresponding to a database query for a certain object and the processing time of each step;

[0133] Obtain target query information and form extracted data through data extraction strategies;

[0134] Acquire a query keyword set and historical query information, wherein the historical query information includes historical query statements and a historical keyword set corresponding to each historical query statement;

[0135] The historical keyword set containing the same keywords as the query keyword set is defined as the historical extraction set;

[0136] If there is a historical extraction set in the historical query information, it is determined to be the first historical data, and the first analysis strategy is executed to form query analysis data;

[0137] If there is no historical extraction set in the historical query information, it is determined to be the second historical data, and the second analysis strategy is executed to form query analysis data;

[0138] According to the mapping data, extraction data, query and analysis data, the judgment data is formed through the data judgment strategy;

[0139] Based on mapping data, extracting data, querying and analyzing data, and judging data, integrated data is formed and query content is extracted through data integration strategies.

[0140] Through the above method, the database is diversified, and according to the historical query information, it is determined whether it is necessary to call the data in the database. According to the data that needs to be queried, it is converted to other databases for query. When the system converts the database, the database with the fastest data processing speed is selected. The data source is sufficient, and the situation where no results are found is reduced. It is avoided that each query extracts information from a large amount of data in the database, thereby improving the query speed and thus improving the processing speed of the overall system during operation.

[0141] Embodiment 2: This embodiment is an improvement made on the basis of embodiment 1. The object-relation SQL mapping method applied to object query and the library analysis strategy are specifically as follows:

[0142] Get the target database;

[0143] Extract all keywords in the target database to form a keyword set;

[0144] Identify each keyword in the keyword set as a target keyword in turn;

[0145] All query data containing the target keyword in the target database are extracted to form a query set for the target keyword. The query data is a statement formed by the programming language used by the target database. If the programming language used by the target database is SQL, the query data is an SQL statement.

[0146] This embodiment also provides that the mapping processing strategy is specifically:

[0147] Get the target database;

[0148] Recognize the databases other than the target database as the first mapping database and the second mapping database respectively;

[0149] sequentially identifying the first mapping database and the second mapping database as target mapping databases;

[0150] Obtain a keyword set of the target database;

[0151] Identify each keyword in the keyword set as a target keyword in turn;

[0152] Obtaining programming data corresponding to the target keyword in the target database as first programming data, wherein the programming data is a programming language, and the first programming data is the programming language corresponding to the target keyword in the target database;

[0153] Obtaining programming data corresponding to the target keyword in the target mapping database as second programming data, wherein the programming data is a programming language, and the second programming data is the programming language corresponding to the target keyword in the target mapping database;

[0154] Obtaining the number of conversion steps for converting the first programming data into the second programming data and the data processing speed when converting the programming data, wherein the process of converting the system from one programming language to another programming language is defined as the programming conversion process, and the program corresponding to the conversion process written by the engineer is defined as the programming conversion program, then the number of conversion steps is the number of code lines of the programming conversion program, and the data processing speed is the average speed of the system processing each line of code of the programming conversion program;

[0155] Calculate the conversion time of converting the first programming data into the second programming data, where the conversion time=the number of conversion steps×the data processing speed;

[0156] All conversion durations are matched one by one with each keyword in the keyword set to form a word conversion set.

[0157] This embodiment also provides that the data extraction strategy is specifically:

[0158] Obtain target query information;

[0159] Extract all keywords in the target query information, define them as query keywords, and form a query keyword set;

[0160] Obtain a query set corresponding to the first database and define it as a main query set;

[0161] Sequentially extract the query set corresponding to each query keyword in the query keyword set in the main query set, and define it as the extracted query set;

[0162] All extraction query sets are matched one by one with the query keyword sets and integrated into a query extraction set.

[0163] Embodiment 3: This embodiment is an improvement made on the basis of Embodiment 2. In this embodiment, the first analysis strategy is specifically:

[0164] S1. Obtain a query keyword set and all historical extraction sets;

[0165] S2, defining a keyword that exists in both the query keyword set and the historical extraction set as the first extraction keyword;

[0166] S3, obtaining the number of historical extraction sets corresponding to each first extraction keyword, and setting it as the number of sets;

[0167] S4. If the number of sets corresponding to all first extracted keywords is the same, execute A1-A3;

[0168] A1. Obtain the number of first extracted keywords contained in each historical extraction set, and define it as the overlap number;

[0169] The historical extraction set with the largest number of overlaps is determined as the priority extraction set;

[0170] Acquire historical query information, where the historical query information includes query results corresponding to each historical query statement in the first database;

[0171] A2. If the number of priority extraction sets = 1, execute B1-B2;

[0172] B1. Extract the historical query statements corresponding to the priority extraction set and set them as the priority extraction statements;

[0173] B2. Extract the query results corresponding to the priority data and set them as the target query results;

[0174] A3. If the number of priority extraction sets is ≠ 1, execute C1-C4;

[0175] C1. Extract the historical query statements corresponding to each priority extraction set and set them as priority analysis statements;

[0176] C2. If all the priority analysis statements are the same statement, the query result corresponding to the statement is extracted and determined as the target query result;

[0177] C3. If all the priority analysis statements are different statements, obtain the historical query time of each priority analysis statement, that is, each priority analysis statement appears only once;

[0178] Get the current time;

[0179] Calculate the interval time, interval time = current time - historical query time;

[0180] Extract the query result corresponding to the priority analysis statement corresponding to the interval duration with the smallest value and set it as the target query result;

[0181] C4. If there are different priority analysis statements, the number of priority extraction sets corresponding to each priority analysis statement is obtained and is defined as the number of statements, that is, the number of occurrences of each priority analysis statement is different;

[0182] The query results corresponding to the statements with the largest number of extracted statements are analyzed first and are set as the target query results;

[0183] S5. If the number of sets corresponding to the first extracted keyword is inconsistent, execute steps D1-D3.

[0184] Wherein, the steps D1-D3 are specifically:

[0185] D1. Obtain the first extracted keyword with the largest number of sets and set it as the priority extracted keyword;

[0186] D2. If the number of keywords to be extracted first = 1, execute E1-E4;

[0187] E1. extract all historical query sentences corresponding to the priority extracted keywords and define them as historical words and sentences;

[0188] E2. If all historical words and sentences are the same sentence, the query result corresponding to the historical words and sentences is extracted and determined as the target query result;

[0189] E3. If all historical words and sentences are different sentences, obtain the historical query time of each historical word and sentence, that is, each historical word and sentence appears only once;

[0190] Get the current time;

[0191] Calculate the interval time, interval time = current time - historical query time;

[0192] Extract the query result corresponding to the historical phrase corresponding to the interval time with the smallest value, and set it as the target query result;

[0193] E4. If there are historical words and sentences that are different sentences, the number of first extracted keywords corresponding to each historical word and sentence is obtained, which is defined as the number of overlapping words, that is, the number of times each historical word and sentence appears is different;

[0194] Extract the query results corresponding to the historical words and sentences with the largest number of overlapping words and set them as the target query results;

[0195] D3. If the number of the priority extracted keywords is ≠ 1, execute F1-F4;

[0196] F1. Extract all historical query sentences corresponding to each priority keyword and set them as preferred sentences;

[0197] F2. If all the preferred words and phrases are the same sentence, the query result corresponding to the preferred word and phrase is extracted and determined as the target query result;

[0198] F3. If all the preferred words and sentences are different sentences, obtain the historical query time of each preferred word and sentence, that is, each historical word and sentence appears only once;

[0199] Get the current time;

[0200] Calculate the interval time, interval time = current time - historical query time;

[0201] Extract the query result corresponding to the interval duration with the smallest value and set it as the target query result;

[0202] F4. If there are preferred words and phrases that are different sentences, the number of first extracted keywords corresponding to each preferred word and phrase is obtained, which is defined as the number of words, that is, the number of times each historical word and phrase appears is different;

[0203] The query result corresponding to the preferred phrase with the largest number of words is extracted and determined as the target query result.

[0204] This embodiment also provides that the second analysis strategy is specifically:

[0205] Obtain a query keyword set and a query extraction set;

[0206] Extracting query data corresponding to each keyword in the query keyword set in the query extraction set, and defining it as query analysis data;

[0207] Extract the number of each query analysis data in the query extraction set, and define it as the query score number, that is, the number of times each query analysis data appears in the query extraction set;

[0208] The query analysis data corresponding to the query score quantity with the largest value is determined as the priority query data;

[0209] Get the number of priority query data, which is defined as the priority query number;

[0210] If the number of priority queries = 1, the priority query data is set as the target query data;

[0211] Obtaining a query result corresponding to the target query data in the first database, and defining it as the target query result;

[0212] If the priority query quantity ≠ 1, obtain the storage data of each priority query data, where the storage data is the storage time of each query data in the first database;

[0213] Get the current time;

[0214] Calculate the storage duration of each priority query data, storage duration = current time - storage data;

[0215] Extract the priority query data corresponding to the storage duration with the smallest value and set it as the target query data;

[0216] The query result corresponding to the target query data in the first database is obtained and is defined as the target query result.

[0217] Embodiment 4: This embodiment is an improvement made on the basis of Embodiment 3. In this embodiment, the data determination strategy is specifically as follows:

[0218] Get the target query results;

[0219] Obtain word conversion sets of the second database and the third database respectively, and define them as a first conversion set and a second conversion set respectively;

[0220] Extract all keywords of the target query results and define them as result keywords;

[0221] Obtain the conversion duration corresponding to each result keyword in the first conversion set, and set it as the first duration;

[0222] Obtain the conversion duration corresponding to each result keyword in the second conversion set, and set it as the second duration;

[0223] Calculate the first conversion duration, where the first conversion duration = the sum of all first durations;

[0224] Calculate the second conversion duration, the second conversion duration = the sum of all second durations;

[0225] If the first conversion time is greater than the second conversion time, the third database is identified as the conversion database;

[0226] If the first conversion time is less than the second conversion time, the second database is identified as the conversion database;

[0227] If the first conversion time length = the second conversion time length, then the number of database data in the second database and the third database is obtained respectively, and is defined as the first database number and the second database number respectively, where the database data number is the number of data available for query stored in the database;

[0228] If the number of the first database is greater than the number of the second database, the second database is identified as the conversion database;

[0229] If the quantity of the first database is less than the quantity of the second database, the third database is identified as the conversion database;

[0230] If the number of the first database = the number of the second database, then the second database or the third database is arbitrarily extracted and identified as the conversion database.

[0231] This embodiment also provides that the data integration strategy is specifically:

[0232] Get the target query results;

[0233] Obtaining a determination result of the target query result, wherein the determination result includes correct and incorrect;

[0234] If the determination result of the target query result is correct, the target query result is used, and the target query result is updated and stored in the historical query information;

[0235] If the determination result of the target query result is an error, the conversion database and all result keywords are obtained;

[0236] Extract the query data containing all the result keywords in the conversion database and define them as the secondary query results;

[0237] Obtaining the determination result of the secondary query result;

[0238] If the determination result of the secondary query result is correct, the secondary query result is used, and the secondary query result is updated and stored in the historical query information;

[0239] If the determination result of the secondary query result is an error, the remaining database is obtained, if the converted database is the second database, the remaining database is the third database, if the converted database is the third database, the remaining database is the second database;

[0240] Extract the query data containing all the result keywords in the remaining database and define them as multiple query results;

[0241] Obtain the determination results of multiple query results;

[0242] If the judgment results of multiple query results are correct, the multiple query results are used, and the multiple query results are updated and stored in the historical query information;

[0243] If the judgment result of multiple query results is wrong, then obtain the query keyword set;

[0244] Extracting all query data containing elements of the query keyword set from the first database, the second database, and the third database to form a complete query set;

[0245] The elements in the complete query set are identified as selection query results in sequence, and the determination results of the selection query results are obtained until the determination results are correct;

[0246] The use result is determined to be a correct selection query result, and the selection query result is updated and stored in the historical query information.

[0247] In this embodiment, the database is multiple, and based on historical query information, it is determined whether it is necessary to call the data in the database. Based on the data that needs to be queried, it is converted to other databases for query. When the system converts the database, the database with the fastest data processing speed is selected. The data source is sufficient, and the situation where no results are found is reduced. It is avoided that each query extracts information from a large amount of data in the database, thereby improving the query speed and thus improving the processing speed of the overall system during operation.

Claims

1. An object-relation SQL mapping method for object query, characterized in that: include: Acquire all databases, where the databases include a first database, a second database, and a third database; Identify each database as a target database in turn, obtain query data from each database through database analysis strategy, execute mapping processing strategy on the target database, and form corresponding mapping data; Obtain target query information and form extracted data through data extraction strategies; Acquire a query keyword set and historical query information, wherein the historical query information includes historical query statements and a historical keyword set corresponding to each historical query statement; The historical keyword set containing the same keywords as the query keyword set is defined as the historical extraction set; If there is a historical extraction set in the historical query information, it is determined to be the first historical data, and the first analysis strategy is executed to form query analysis data; If there is no historical extraction set in the historical query information, it is determined to be the second historical data, and the second analysis strategy is executed to form query analysis data; According to the mapping data, extraction data, query and analysis data, the judgment data is formed through the data judgment strategy; Based on mapping data, extracting data, querying and analyzing data, and judging data, integrated data is formed and query content is extracted through data integration strategies.

2. The object-relationship SQL mapping method for object query according to claim 1, characterized in that: The library analysis strategy is specifically as follows: Get the target database; Extract all keywords in the target database to form a keyword set; Identify each keyword in the keyword set as a target keyword in turn; Extract all query data containing the target keyword in the target database to form a query set for the target keyword.

3. The object-relationship SQL mapping method for object query according to claim 1, characterized in that: The mapping processing strategy is specifically: Get the target database; Recognize the databases other than the target database as the first mapping database and the second mapping database respectively; sequentially identifying the first mapping database and the second mapping database as target mapping databases; Obtain a keyword set of the target database; Identify each keyword in the keyword set as a target keyword in turn; Obtaining programming data corresponding to the target keyword in the target database, and defining the data as first programming data; Obtaining programming data corresponding to the target keyword in the target mapping database as second programming data; Acquire the number of conversion steps for converting the first programming data into the second programming data and the data processing speed when converting the programming data; Calculate the conversion time of converting the first programming data into the second programming data, where the conversion time=the number of conversion steps×the data processing speed; All conversion durations are matched one by one with each keyword in the keyword set to form a word conversion set.

4. The object-relationship SQL mapping method for object query according to claim 1, characterized in that: The data extraction strategy is specifically as follows: Obtain target query information; Extract all keywords in the target query information, define them as query keywords, and form a query keyword set; Obtain a query set corresponding to the first database and define it as a main query set; Sequentially extract the query set corresponding to each query keyword in the query keyword set in the main query set, and define it as the extracted query set; All extraction query sets are matched one by one with the query keyword sets and integrated into a query extraction set.

5. The object-relationship SQL mapping method for object query according to claim 1, characterized in that: The first analysis strategy is specifically: S1. Obtain a query keyword set and all historical extraction sets; S2, defining a keyword that exists in both the query keyword set and the historical extraction set as the first extraction keyword; S3, obtaining the number of historical extraction sets corresponding to each first extraction keyword, and setting it as the number of sets; S4. If the number of sets corresponding to all first extracted keywords is the same, execute A1-A3; A1. Obtain the number of first extracted keywords contained in each historical extraction set, and define it as the overlap number; The historical extraction set with the largest number of overlaps is determined as the priority extraction set; Acquire historical query information, where the historical query information includes query results corresponding to each historical query statement in the first database; A2. If the number of priority extraction sets = 1, execute B1-B2; B1. Extract the historical query statements corresponding to the priority extraction set and set them as the priority extraction statements; B2. Extract the query results corresponding to the priority data and set them as the target query results; A3. If the number of priority extraction sets is ≠ 1, execute C1-C4; C1. Extract the historical query statements corresponding to each priority extraction set and set them as priority analysis statements; C2. If all the priority analysis statements are the same statement, the query result corresponding to the statement is extracted and determined as the target query result; C3. If all the priority analysis statements are different statements, obtain the historical query time of each priority analysis statement; Get the current time; Calculate the interval time, interval time = current time - historical query time; Extract the query result corresponding to the priority analysis statement corresponding to the interval duration with the smallest value and set it as the target query result; C4. If there are priority analysis statements that are different statements, obtain the number of priority extraction sets corresponding to each priority analysis statement, and set it as the number of statements; The query results corresponding to the statements with the largest number of extracted statements are analyzed first and are set as the target query results; S5. If the number of sets corresponding to the first extracted keyword is inconsistent, execute steps D1-D3.

6. The object-relationship SQL mapping method for object query according to claim 5, characterized in that: The steps D1-D3 are specifically: D1. Obtain the first extracted keyword with the largest number of sets and set it as the priority extracted keyword; D2. If the number of keywords to be extracted first = 1, execute E1-E4; E1. Extract all historical query sentences corresponding to the priority extracted keywords and define them as historical words and sentences; E2. If all historical words and sentences are the same sentence, the query result corresponding to the historical words and sentences is extracted and determined as the target query result; E3. If all historical words and sentences are different sentences, obtain the historical query time of each historical word and sentence; Get the current time; Calculate the interval time, interval time = current time - historical query time; Extract the query result corresponding to the historical phrase corresponding to the interval time with the smallest value, and set it as the target query result; E4. If there are historical words and sentences that are different sentences, the number of first extracted keywords corresponding to each historical word and sentence is obtained, which is defined as the number of overlapping words; Extract the query results corresponding to the historical words and sentences with the largest number of overlapping words and set them as the target query results; D3. If the number of the priority extracted keywords is ≠ 1, execute F1-F4; F1. Extract all historical query sentences corresponding to each priority keyword and set them as preferred sentences; F2. If all the preferred words and phrases are the same sentence, the query result corresponding to the preferred word and phrase is extracted and determined as the target query result; F3. If all the preferred words and sentences are different sentences, obtain the historical query time of each preferred word and sentence; Get the current time; Calculate the interval time, interval time = current time - historical query time; Extract the query result corresponding to the interval duration with the smallest value and set it as the target query result; F4. If there are preferred words and phrases that are different sentences, the number of first extracted keywords corresponding to each preferred word and phrase is obtained, which is determined as the number of extracted words; The query result corresponding to the preferred phrase with the largest number of words is extracted and determined as the target query result.

7. The object-relationship SQL mapping method for object query according to claim 1, characterized in that: The second analysis strategy is specifically: Obtain a query keyword set and a query extraction set; Extracting query data corresponding to each keyword in the query keyword set in the query extraction set, and defining it as query analysis data; Extract the number of each query analysis data in the query extraction set and define it as the query score number; The query analysis data corresponding to the query score quantity with the largest value is determined as the priority query data; Get the number of priority query data, which is defined as the priority query number; If the number of priority queries = 1, the priority query data is set as the target query data; Obtaining a query result corresponding to the target query data in the first database, and defining it as the target query result; If the number of priority queries ≠ 1, obtain the storage data of each priority query data; Get the current time; Calculate the storage duration of each priority query data, storage duration = current time - storage data; Extract the priority query data corresponding to the storage duration with the smallest value and set it as the target query data; The query result corresponding to the target query data in the first database is obtained and is defined as the target query result.

8. The object-relationship SQL mapping method for object query according to claim 1, characterized in that: The data determination strategy is specifically as follows: Get the target query results; Obtain word conversion sets of the second database and the third database respectively, and define them as a first conversion set and a second conversion set respectively; Extract all keywords of the target query results and define them as result keywords; Obtain the conversion duration corresponding to each result keyword in the first conversion set, and set it as the first duration; Obtain the conversion duration corresponding to each result keyword in the second conversion set, and set it as the second duration; Calculate the first conversion duration, where the first conversion duration = the sum of all first durations; Calculate the second conversion duration, the second conversion duration = the sum of all second durations; If the first conversion time is greater than the second conversion time, the third database is identified as the conversion database; If the first conversion time is less than the second conversion time, the second database is identified as the conversion database; If the first conversion time length = the second conversion time length, the number of database data in the second database and the third database are obtained respectively, and are set as the first database number and the second database number respectively; If the number of the first database is greater than the number of the second database, the second database is identified as the conversion database; If the quantity of the first database is less than the quantity of the second database, the third database is identified as the conversion database; If the number of the first database = the number of the second database, then the second database or the third database is arbitrarily extracted and identified as the conversion database.

9. The object-relationship SQL mapping method for object query according to claim 1, characterized in that: The data integration strategy is specifically as follows: Get the target query results; Obtaining a determination result of the target query result, wherein the determination result includes correct and incorrect; If the determination result of the target query result is correct, the target query result is used, and the target query result is updated and stored in the historical query information; If the determination result of the target query result is an error, the conversion database and all result keywords are obtained; Extract the query data containing all the result keywords in the conversion database and define them as the secondary query results; Obtaining the determination result of the secondary query result; If the determination result of the secondary query result is correct, the secondary query result is used, and the secondary query result is updated and stored in the historical query information; If the determination result of the secondary query result is an error, the remaining database is obtained; Extract the query data containing all the result keywords in the remaining database and define them as multiple query results; Obtaining the determination results of multiple query results; If the judgment results of multiple query results are correct, the multiple query results are used, and the multiple query results are updated and stored in the historical query information; If the judgment result of multiple query results is wrong, then obtain the query keyword set; Extracting all query data containing elements of the query keyword set from the first database, the second database, and the third database to form a complete query set; The elements in the complete query set are identified as selection query results in sequence, and the determination results of the selection query results are obtained until the determination results are correct; The use result is determined to be a correct selection query result, and the selection query result is updated and stored in the historical query information.

Citation Information

Patent Citations

  • Database-independent SQL statement generation method

    CN116340337A

  • Method for automatically generating database query statement based on NLP language model

    CN116991869A