Data query method and device based on general model

By extracting non-duplicate fields from multiple data models to establish a common model and create indexes, the problem of too many data models and indexes in the existing technology is solved, maintenance costs and coupling are reduced, and development efficiency and database performance are improved.

CN110110211BActive Publication Date: 2024-10-18BEIJING JINGDONG SHANGKE INFORMATION TECH CO LTD +1
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN201810058806.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2018-01-22
Publication Date
2024-10-18
Estimated Expiration
2038-01-22

AI Technical Summary

Technical Problem

In the existing technology, in order to reduce query response time, it is necessary to establish data models and indexes for each of the most granular query scenarios, resulting in a large number of data models and indexes, increasing high maintenance costs, and affecting database writing. performance, high front-end and back-end coupling, and long development time.

Method used

By extracting non-duplicate fields from multiple data models, a universal model is established, the query condition fields and pre-calculated result fields are stored in the universal model according to non-duplicate fields, and indexes are created in the universal model, thereby reducing the complexity of data models and indexes. quantity, reduce maintenance costs and coupling, and improve development efficiency and writing performance.

Benefits of technology

Without affecting query efficiency, it reduces the number of data models and indexes, reduces database maintenance costs and front-end and back-end coupling, improves the efficiency of front-end application development and modification, and improves database writing performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN110110211B_ABST
    Figure CN110110211B_ABST
Patent Text Reader

Abstract

The present invention discloses a data query method and device based on a general model, and relates to the field of computer technology. A specific implementation of the method includes: determining non-repeating fields from fields of multiple data models corresponding to different query scenarios; wherein the fields of each data model in the multiple data models include: query condition fields and pre-calculated result fields; establishing a general model using the non-repeating fields, and storing the query condition field data and pre-calculated result field data in the multiple data models in the general model according to the non-repeating fields; in response to the query statements of the different query scenarios, selecting the query result data corresponding to the query statement from the pre-calculated result field data stored in the general model and returning it. This implementation can reduce the number of data models without affecting the query efficiency, thereby reducing the database maintenance cost and the coupling degree of the front-end and back-end.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a data query method and device based on a general model. Background Art

[0002] In the field of data applications, there are often a large number of different query scenarios, each of which corresponds to a query statement such as a Structured Query Language (SQL) statement. In practical applications, in order to reduce query response time and improve user experience, the user's possible query results can be pre-calculated, and a data model can be established for each query scenario to save the pre-calculated result data. At the same time, as the amount of data continues to increase, it is necessary to create indexes on reasonable fields of the data model according to different query scenarios to speed up the query.

[0003] In the process of implementing the present invention, the inventors found that the prior art has at least the following problems:

[0004] 1. In the prior art, it is generally necessary to establish a data model and index for each most fine-grained query scenario, thus generating a large number of data models and indexes, which brings high maintenance costs.

[0005] 2. A large number of indexes in the existing technology will seriously affect the writing performance of the database, resulting in slower data updates.

[0006] 3. Due to the existence of a large number of data models in the existing technology, the front-end functional code needs to embed a large number of query statements. Moreover, when the front-end application is modified, the code modification amount is large and it also depends on the development progress of the back-end model, which makes the coupling degree between the front-end and the back-end high, and the overall system development time and joint debugging time are long. Summary of the invention

[0007] In view of this, an embodiment of the present invention provides a data query method and device based on a general model, which can reduce the number of data models without affecting the query efficiency, thereby reducing the database maintenance cost and the coupling degree between the front-end and the back-end.

[0008] To achieve the above objective, according to one aspect of the present invention, a data query method based on a general model is provided.

[0009] The data query method based on a general model of an embodiment of the present invention includes: determining non-repeated fields from the fields of multiple data models corresponding to different query scenarios; wherein the fields of each data model in the multiple data models include: a query condition field and a pre-calculated result field; establishing a general model using the non-repeated fields, and storing the query condition field data and the pre-calculated result field data in the multiple data models in the general model according to the non-repeated fields; and, in response to the query statements of the different query scenarios, selecting the query result data corresponding to the query statement from the pre-calculated result field data stored in the general model and returning it.

[0010] Optionally, storing the query condition field data and pre-calculated result field data in the multiple data models in the common model according to the non-repeated fields includes: for any record of any data model: maintaining the values ​​of its query condition field and pre-calculated result field in the data model, using a preset non-query mark value as the value of a newly added query condition field in the common model, and storing the modified record in the common model according to the non-repeated fields; wherein the newly added query condition field is: the query condition field in the non-repeated fields except the query condition field of the data model.

[0011] Optionally, the method further includes: after storing the query condition field data and pre-calculated result field data in the multiple data models in the common model according to the non-repeated fields, determining the non-repeated index fields from the index fields in the multiple data models, and creating an index for the non-repeated index fields in the common model.

[0012] Optionally, selecting and returning query result data corresponding to the query statement from the pre-calculated result field data stored in the general model includes: selecting and returning query result data corresponding to the query statement from the pre-calculated result field data stored in the general model using an index created in the general model.

[0013] Optionally, for a query statement in any of the different query scenarios, its query condition clause includes: the value of the query condition field of the data model corresponding to the query scenario, and the non-query mark value of a newly added query condition field of the data model; wherein the newly added query condition field of the data model is: the query condition fields in the non-repeated fields except the query condition fields of the data model.

[0014] Optionally, the multiple data models and the general model are all data tables, the query statement is a structured query language SQL statement, and the query condition clause is a WHERE clause.

[0015] To achieve the above objective, according to another aspect of the present invention, a data query device based on a general model is provided.

[0016] A data query device based on a general model in an embodiment of the present invention may include: a deduplication unit, which can be used to determine non-repeated fields from the fields of multiple data models corresponding to different query scenarios; wherein the fields of each data model in the multiple data models include: a query condition field and a pre-calculated result field; a general model generation unit, which can be used to establish a general model using the non-repeated fields, and store the query condition field data and the pre-calculated result field data in the multiple data models in the general model according to the non-repeated fields; and a query unit, which can be used to respond to query statements of the different query scenarios, and select the query result data corresponding to the query statement from the pre-calculated result field data stored in the general model and return it.

[0017] Optionally, the general model generation unit can be further used to: for any record of any data model: maintain the values ​​of its query condition field and pre-calculated result field in the data model, use the preset non-query mark value as the value of the newly added query condition field in the general model, and store the modified record in the general model according to the non-repeated field; wherein the newly added query condition field is: the query condition field in the non-repeated field except the query condition field of the data model.

[0018] Optionally, the device may further include: an index creation unit, which is used to determine non-repeated index fields from the index fields in the multiple data models after storing the query condition field data and pre-calculated result field data in the multiple data models in the common model according to the non-repeated fields, and create an index for the non-repeated index fields in the common model.

[0019] Optionally, the query unit may be further configured to: select query result data corresponding to the query statement from the pre-calculated result field data stored in the general model using an index created in the general model and return the query result data.

[0020] Optionally, for a query statement in any of the different query scenarios, its query condition clause includes: the value of the query condition field of the data model corresponding to the query scenario, and the non-query mark value of a newly added query condition field of the data model; wherein the newly added query condition field of the data model is: the query condition fields in the non-repeated fields except the query condition fields of the data model.

[0021] Optionally, the multiple data models and the general model are all data tables, the query statement is a structured query language SQL statement, and the query condition clause is a WHERE clause.

[0022] To achieve the above objective, according to another aspect of the present invention, an electronic device is provided.

[0023] An electronic device of the present invention includes: one or more processors; a storage device for storing one or more programs, when the one or more programs are executed by the one or more processors, the one or more processors implement the general model-based data query method provided by the present invention.

[0024] To achieve the above objective, according to yet another aspect of the present invention, a computer-readable storage medium is provided.

[0025] A computer-readable storage medium of the present invention stores a computer program, which, when executed by a processor, implements the data query method based on a general model provided by the present invention.

[0026] According to the technical solution of the present invention, an embodiment of the above invention has the following advantages or beneficial effects: a general model is established by extracting non-repeated fields from multiple data models corresponding to different query scenarios, and all the data stored in the data model are stored in the general model according to the non-repeated fields, so that the general model can be applied to all query scenarios of the original data model, thereby reducing the number of data models, reducing the database maintenance cost and the coupling degree of the front-end and back-end, and improving the efficiency of front-end application development and modification; in addition, the present invention determines the non-repeated index field from the index field of the original data model, creates an index for the non-repeated index field in the general model to obtain a general index, thereby reducing the number of indexes and improving the write performance of the database without affecting the query speed.

[0027] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.

[0029] Figure 1 is a schematic diagram of main steps of a data query method based on a general model according to an embodiment of the present invention;

[0030] Figure 2 is a schematic diagram of the main parts of a data query device based on a general model according to an embodiment of the present invention;

[0031] Figure 3 is an exemplary system architecture diagram in which embodiments of the present invention may be applied;

[0032] Figure 4It is a schematic diagram of the structure of an electronic device used to implement the data query method based on a general model according to an embodiment of the present invention. DETAILED DESCRIPTION

[0033] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.

[0034] In the technical solution of the embodiment of the present invention, a general model is established by extracting non-repeated fields from multiple data models corresponding to different query scenarios, and all the data stored in the data model are stored in the general model according to the non-repeated fields, so that the general model can be applied to all query scenarios of the original data model, thereby reducing the number of data models, reducing the database maintenance cost and the coupling degree of the front-end and back-end, and improving the efficiency of front-end application development and modification; in addition, the present invention determines the non-repeated index field from the index field of the original data model, creates an index for the non-repeated index field in the general model to obtain a general index, thereby reducing the number of indexes and improving the write performance of the database without affecting the query speed.

[0035] It should be pointed out that the embodiments of the present invention and the technical features therein may be combined with each other without conflict.

[0036] Figure 1 It is a schematic diagram of main steps of a data query method based on a general model according to an embodiment of the present invention.

[0037] like Figure 1 As shown, the data query method based on the general model in the embodiment of the present invention can perform the following steps:

[0038] Step S101: determining non-repetitive fields from fields of multiple data models corresponding to different query scenarios.

[0039] In this step, the query scenario can select the most fine-grained scenario according to the application environment, such as the scenario corresponding to a certain query statement. For example, the following are two query scenarios for the source data table of the business database and their corresponding SQL query statements:

[0040] Scenario 1: Query the sales volume of each first-level category item every day. The SQL statement is:

[0041] select date,lvl1_id,sum(num)from table group by date,lvl1_id

[0042] Scenario 2: Query the sales volume of each secondary category item every day. The SQL statement is:

[0043] select date,lvl2_id,sum(num)from table group by date,lvl2_id

[0044] Among them, table is the source data table, date, lvl1_id, lvl2_id, and num are the date, first-level category ID, second-level category ID, and sales volume fields in the table respectively, sum is an aggregate function, and select and group are selection and grouping statements respectively.

[0045] In practical applications, in order to speed up the query, a data model can be established for each query scenario, and the possible query results of the user can be determined and stored in the data model in advance before the user queries. In an embodiment of the present invention, the data model can be a data table. The following are the data models corresponding to the two query scenarios in the above example:

[0046] Data model 1 (corresponding to query scenario 1)

[0047] date lvl1_id amount a1 b1 c1 a2 b2 c2 a3 b3 c3

[0048] Data model 2 (corresponding to query scenario 2)

[0049] date lvl2_id amount a4 d1 c4 a5 d2 c5 a6 d3 c6

[0050] Among them, only three records are shown in each data model. Amount is the total sales field, which is used to store the pre-calculated result of the sum function. In data model 1, date and lvl1_id are query condition fields, and amount is the pre-calculated result field; in data model 2, date and lvl2_id are query condition fields, and amount is the pre-calculated result field.

[0051] In this step, non-repeated fields can be determined in the fields of multiple data models. Among them, non-repeated fields refer to the field dimensions that remain after deduplication in all field dimensions of the data model. In practical applications, fields with different field names in the data model can be used as non-repeated fields. For example: In the above example, the date field and amount field names of data model one and data model two are the same, then the non-repeated fields obtained after deduplication from all fields of data models one and two are: date, lvl1_id, lvl2_id, amount. Obviously, non-repeated fields also include query condition fields and pre-calculated result fields. For example: Among the above non-repeated fields, date, lvl1_id, lvl2_id are query condition fields, and amount is a pre-calculated result field.

[0052] Step S102: establishing a common model using non-repeated fields, and storing query condition field data and pre-calculated result field data in multiple data models in the common model according to non-repeated fields.

[0053] Specifically, in this step, the non-repeated fields determined in step S101 can be used as fields of the general model, and all data of the data model can be stored in the general model. In practical applications, the general model can be a data table. When storing data, for each record of each data model: keep the values ​​of its query condition field and pre-calculated result field in the data model, use the preset non-query mark value as the value of the newly added query condition field in the general model, and store the modified record in the general model. That is, for each data model, the general model often contains query condition fields that do not exist in the data model (i.e., newly added query condition fields). When any record of the data model is stored in the general model, its original fields are maintained (i.e., remain unchanged), and the newly added query condition fields are set to non-query mark values ​​such as -99. For example: the following general model can be determined based on the two data models in the above example:

[0054]

[0055]

[0056] In step S102, an index can also be created in the general model according to the index fields of the data model to speed up the query. Specifically, first determine the non-re-indexed fields from all the index fields of the multiple data models, and then create an index for the non-re-indexed fields in the general model to generate a general index for data query in the general model, thereby realizing all the index functions of the original data model in the general model. Among them, the non-re-indexed fields refer to the index fields remaining after deduplication in all the index fields of the multiple data models. For example: If the index field of data model one in the above example is lvl1_id, and the index field of data model two is lvl2_id, there is no duplicate index field, and the non-re-indexed fields are lvl1_id and lvl2_id. An index can be created for the lvl1_id field and the lvl2_id field in the general model to obtain a general index, thereby realizing all the functions of the original index.

[0057] Through steps S101 and S102, the present invention can effectively reduce the number of data models and the number of indexes in the data models without affecting the query efficiency, thereby reducing the database maintenance cost and the coupling degree of the front-end and back-end, improving the development and modification efficiency of the front-end application, and optimizing the write performance of the database.

[0058] Step S103: In response to query statements of different query scenarios, query result data corresponding to the query statements are selected from the pre-calculated result field data stored in the general model and returned.

[0059] In this step, the general model established in steps S101 and S102 can be used to query data. Since the general model contains non-query tag values, non-query tag values ​​can be added to the query statement.

[0060] Specifically, for a query statement in any query scenario, its query condition clause, such as the SQL WHERE clause, may include: the value of the query condition field of the data model corresponding to the query scenario and the non-query tag value of the newly added query condition field of the data model. For example, when using the general model (table1) in the above example to query data, the following SQL query statement can be used:

[0061] When querying the sales volume of a first-level category item (identified as y) on a certain day (date is x), the SQL statement is:

[0062] select date,lvl1_id,lvl2_id,amount from table1where date=x and lvl1_id=y and lvl2_id=-99

[0063] When querying the sales volume of a secondary category item (identified as z) on a certain day (date x), the SQL statement is:

[0064] select date,lvl1_id,lvl2_id,amount from table1where date=x and lvl1_id=-99and lvl2_id=z

[0065] In this step, after receiving the above query statement, the query result data to be returned can be determined in the pre-calculated result field data (such as c1-c6) stored in the common model, thereby replacing the original multiple data models with one common model for data query, which can be applied to all query scenarios corresponding to the original multiple data models.

[0066] It is understandable that although SQL is used as an example above, the data query method based on the general model in the embodiment of the present invention can be applied to any applicable database such as MYSQL, ORACLE, DB2, Sybase, etc.

[0067] In the technical solution of the embodiment of the present invention, a general model is established by extracting non-repeated fields from multiple data models corresponding to different query scenarios, and all the data stored in the data model are stored in the general model according to the non-repeated fields, so that the general model can be applied to all query scenarios of the original data model, thereby reducing the number of data models, reducing the database maintenance cost and the coupling degree of the front-end and back-end, and improving the efficiency of front-end application development and modification; in addition, the present invention determines the non-repeated index field from the index field of the original data model, creates an index for the non-repeated index field in the general model to obtain a general index, thereby reducing the number of indexes and improving the write performance of the database without affecting the query speed.

[0068] Figure 2 It is a schematic diagram of the main parts of the data query device based on the general model according to an embodiment of the present invention.

[0069] like Figure 2 As shown, the data query device 200 based on the general model according to the embodiment of the present invention may include: a deduplication unit 201, a general model generation unit 202 and a query unit 203. Among them:

[0070] The deduplication unit 201 may be used to determine non-duplicate fields from fields of multiple data models corresponding to different query scenarios; wherein the fields of each data model in the multiple data models include: a query condition field and a pre-calculated result field;

[0071] The general model generating unit 202 may be used to establish a general model using the non-repeated fields, and store the query condition field data and the pre-calculated result field data in the plurality of data models in the general model according to the non-repeated fields;

[0072] The query unit 203 may be configured to respond to query statements of the different query scenarios and select query result data corresponding to the query statements from the pre-calculated result field data stored in the general model and return the query result data.

[0073] In an embodiment of the present invention, the general model generation unit 202 can be further used to: for any record of any data model: maintain the values ​​of its query condition field and pre-calculated result field in the data model, use the preset non-query mark value as the value of the newly added query condition field in the general model, and store the modified record in the general model according to the non-repeated field; wherein the newly added query condition field is: the query condition field in the non-repeated field except the query condition field of the data model.

[0074] As a preferred scheme, the device 200 may further include: an index creation unit, which is used to determine non-repeated index fields from the index fields in the multiple data models after storing the query condition field data and pre-calculated result field data in the multiple data models according to the non-repeated fields in the common model, and create an index for the non-repeated index field in the common model.

[0075] Preferably, in the embodiment of the present invention, the query unit 203 may be further configured to: select query result data corresponding to the query statement from the pre-calculated result field data stored in the general model using the index created in the general model and return it.

[0076] In actual applications, for a query statement in any of the different query scenarios, its query condition clause includes: the value of the query condition field of the data model corresponding to the query scenario, and the non-query mark value of the newly added query condition field of the data model; wherein the newly added query condition field of the data model is: the query condition field in the non-repeated fields except the query condition field of the data model.

[0077] In an optional implementation, the multiple data models and the general model are all data tables, the query statement is a structured query language SQL statement, and the query condition clause is a WHERE clause.

[0078] In the technical solution of the embodiment of the present invention, a general model is established by extracting non-repeated fields from multiple data models corresponding to different query scenarios, and all the data stored in the data model are stored in the general model according to the non-repeated fields, so that the general model can be applied to all query scenarios of the original data model, thereby reducing the number of data models, reducing the database maintenance cost and the coupling degree of the front-end and back-end, and improving the efficiency of front-end application development and modification; in addition, the present invention determines the non-repeated index field from the index field of the original data model, creates an index for the non-repeated index field in the general model to obtain a general index, thereby reducing the number of indexes and improving the write performance of the database without affecting the query speed.

[0079] Figure 3 An exemplary system architecture 300 is shown to which a general model-based data query method or a general model-based data query device according to an embodiment of the present invention can be applied.

[0080] like Figure 3 As shown, the system architecture 300 may include terminal devices 301, 302, 303, a network 304 and a server 305 (this architecture is only an example, and the components included in the specific architecture may be adjusted according to the specific application). The network 304 is used to provide a medium for a communication link between the terminal devices 301, 302, 303 and the server 305. The network 304 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0081] Users can use terminal devices 301, 302, 303 to interact with server 305 through network 304 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 301, 302, 303, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only examples).

[0082] The terminal devices 301 , 302 , and 303 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers, etc.

[0083] The server 305 may be a server that provides various services, such as a backend management server (only an example) that provides support for shopping websites browsed by users using the terminal devices 301, 302, and 303. The backend management server may analyze and process the received product information query request and other data, and feed back the processing results (such as target push information, product information - only an example) to the terminal device.

[0084] It should be noted that the data query method based on the general model provided in the embodiment of the present invention is generally executed by the server 305 , and accordingly, the data query device based on the general model is generally set in the server 305 .

[0085] It should be understood that Figure 3 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to the implementation requirements.

[0086] The present invention also provides an electronic device. The electronic device of an embodiment of the present invention includes: one or more processors; a storage device for storing one or more programs, when the one or more programs are executed by the one or more processors, the one or more processors implement the data query method based on the general model provided by the present invention.

[0087] Reference below Figure 4 , which shows a schematic diagram of the structure of a computer system 400 of an electronic device suitable for implementing an embodiment of the present invention. Figure 4 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0088] like Figure 4 As shown, the computer system 400 includes a central processing unit (CPU) 401, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 402 or a program loaded from a storage part 408 into a random access memory (RAM) 403. In the RAM 403, various programs and data required for the operation of the computer system 400 are also stored. The CPU 601, the ROM 402, and the RAM 403 are connected to each other via a bus 404. An input / output (I / O) interface 405 is also connected to the bus 404.

[0089] The following components are connected to the I / O interface 405: an input section 406 including a keyboard, a mouse, etc.; an output section 407 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 408 including a hard disk, etc.; and a communication section 409 including a network interface card such as a LAN card, a modem, etc. The communication section 409 performs communication processing via a network such as the Internet. A drive 410 is also connected to the I / O interface 405 as needed. A removable medium 411, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 410 as needed so that a computer program read therefrom is installed into the storage section 408 as needed.

[0090] In particular, according to the embodiments disclosed in the present invention, the process described in the main step diagram above can be implemented as a computer software program. For example, an embodiment of the present invention includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains program code for executing the method shown in the main step diagram. In the above embodiment, the computer program can be downloaded and installed from the network through the communication part 409, and / or installed from the removable medium 411. When the computer program is executed by the central processing unit 401, the above functions defined in the system of the present invention are executed.

[0091] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer readable signal media may also be any computer readable medium other than computer readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0092] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the above-mentioned module, program segment or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0093] The units involved in the embodiments of the present invention may be implemented by software or hardware. The units described may also be provided in a processor, for example, may be described as: a processor including a deduplication unit, a general model generation unit, and a query unit. The names of these units do not, in some cases, constitute limitations on the units themselves, for example, a deduplication unit may also be described as a "unit that sends non-duplicate fields to a general model generation unit".

[0094] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently and not be assembled into the device. The above computer-readable medium carries one or more programs. When the above one or more programs are executed by the device, the steps executed by the device include: determining non-repeated fields from the fields of multiple data models corresponding to different query scenarios; wherein the fields of each data model in the multiple data models include: query condition fields and pre-calculated result fields; establishing a general model using the non-repeated fields, and storing the query condition field data and pre-calculated result field data in the multiple data models in the general model according to the non-repeated fields; and, in response to the query statements of the different query scenarios, selecting the query result data corresponding to the query statement from the pre-calculated result field data stored in the general model and returning the query result data.

[0095] In the technical solution of the embodiment of the present invention, a general model is established by extracting non-repeated fields from multiple data models corresponding to different query scenarios, and all the data stored in the data model are stored in the general model according to the non-repeated fields, so that the general model can be applied to all query scenarios of the original data model, thereby reducing the number of data models, reducing the database maintenance cost and the coupling degree of the front-end and back-end, and improving the efficiency of front-end application development and modification; in addition, the present invention determines the non-repeated index field from the index field of the original data model, creates an index for the non-repeated index field in the general model to obtain a general index, thereby reducing the number of indexes and improving the write performance of the database without affecting the query speed.

[0096] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A data query method based on a general model, characterized in that: include: Determine non-repeated fields from fields of multiple data models corresponding to different query scenarios; wherein the fields of each data model in the multiple data models include: a query condition field and a pre-calculated result field; Establishing a general model by using the non-repeated fields, and storing the query condition field data and the pre-calculated result field data in the multiple data models in the general model according to the non-repeated fields; Determine a non-re-indexed field from the index fields in the multiple data models, and create an index for the non-re-indexed field in the common model; In response to the query statements of the different query scenarios, query result data corresponding to the query statements are selected from the pre-calculated result field data stored in the general model and returned; The selecting and returning the query result data corresponding to the query statement from the pre-calculated result field data stored in the general model includes: selecting and returning the query result data corresponding to the query statement from the pre-calculated result field data stored in the general model using the index created in the general model.

2. The method according to claim 1, characterized in that: The storing the query condition field data and the pre-calculated result field data in the multiple data models in the common model according to the non-repeated fields comprises: For any record of any data model: keep the values ​​of its query condition field and pre-calculated result field in the data model, use the preset non-query mark value as the value of the newly added query condition field in the general model, and store the modified record in the general model according to the non-repeated field; The newly added query condition fields are: query condition fields in the non-repeated fields except the query condition fields of the data model.

3. The method according to claim 2, characterized in that For a query statement in any query scenario in the different query scenarios, the query condition clause includes: the value of the query condition field of the data model corresponding to the query scenario, and the non-query tag value of the newly added query condition field of the data model; wherein, The newly added query condition fields of the data model are: the query condition fields in the non-repeated fields except the query condition fields of the data model.

4. The method according to claim 3, characterized in that The multiple data models and the general model are all data tables, the query statement is a structured query language SQL statement, and the query condition clause is a WHERE clause.

5. A data query device based on a general model, characterized in that: include: A deduplication unit, configured to determine non-duplicate fields from fields of a plurality of data models corresponding to different query scenarios; wherein the fields of each data model in the plurality of data models include: a query condition field and a pre-calculated result field; A general model generating unit, configured to establish a general model by using the non-repeated fields, and store the query condition field data and the pre-calculated result field data in the plurality of data models in the general model according to the non-repeated fields; An index creation unit, configured to determine a non-re-indexed field from the index fields in the plurality of data models, and create an index for the non-re-indexed field in the common model; A query unit, configured to respond to query statements of the different query scenarios and select query result data corresponding to the query statements from the pre-calculated result field data stored in the general model and return the query result data; The query unit is further used to: select the query result data corresponding to the query statement from the pre-calculated result field data stored in the general model using the index created in the general model and return it.

6. The device according to claim 5, characterized in that The general model generation unit is further used to: For any record of any data model: keep the values ​​of its query condition field and pre-calculated result field in the data model, use the preset non-query mark value as the value of the newly added query condition field in the general model, and store the modified record in the general model according to the non-repeated field; wherein the newly added query condition field is: the query condition field in the non-repeated field except the query condition field of the data model.

7. The device according to claim 6, characterized in that For a query statement in any query scenario in the different query scenarios, its query condition clause includes: the value of the query condition field of the data model corresponding to the query scenario, and the non-query tag value of the newly added query condition field of the data model; wherein the newly added query condition field of the data model is: the query condition field in the non-repeated fields except the query condition field of the data model.

8. The device according to claim 7, characterized in that The multiple data models and the general model are all data tables, the query statement is a structured query language SQL statement, and the query condition clause is a WHERE clause.

9. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 4.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.

Citation Information

Patent Citations

  • Unique index creation method and apparatus, and uniqueness query method and apparatus

    CN106919637A