A data query method, apparatus, device, system, and storage medium

By acquiring and parsing the definition information of lightweight data storage format, and autonomously accessing the database to assemble data, the flexibility and efficiency issues when the data table structure or JSON format changes are resolved, achieving efficient data querying and reducing code adjustment costs.

CN114676163BActive Publication Date: 2025-10-31CHINA CONSTRUCTION BANK
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202210305980.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-25
Publication Date
2025-10-31
Estimated Expiration
2042-03-25

AI Technical Summary

Technical Problem

In existing technologies, when the data table structure or JSON format changes, the data query and format conversion code needs to be adjusted, resulting in poor flexibility and low efficiency.

Method used

By acquiring the definition information of a preset lightweight data storage format, including model import attribute information and model definition information, this information is parsed to autonomously access the database and assemble data, avoiding direct adjustment of the data access and assembly code.

Benefits of technology

It improves data query efficiency, enhances flexibility, and reduces the manpower cost of code adjustments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114676163B_ABST
    Figure CN114676163B_ABST
Patent Text Reader

Abstract

This invention discloses a data query method, apparatus, device, and storage medium. The invention relates to the field of cloud computing security service technology. The method includes: responding to a received data query request by obtaining definition information of a preset lightweight data storage format; parsing the definition information, and when model-introduced attribute information is parsed, obtaining model definition information of the data model specified by the model-introduced attribute information; performing a query operation on the data table specified by the obtained model definition information; and obtaining query result data in the lightweight data storage format based on the query results. In the method of this invention, by defining a lightweight data storage format, data can be assembled autonomously by accessing the database according to the definition information. Furthermore, when the data table structure or lightweight data storage format changes, there is no need to adjust the data access and assembly code, providing high flexibility.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the field of cloud computing security service technology, and in particular to a data query method, apparatus, device, system and storage medium. Background Technology

[0002] JSON (JavaScript Object Notation) is a lightweight, programming language-independent data storage format and a standard specification. Due to its lightweight nature, ease of reading, writing, parsing, and cross-platform / multi-language support, lightweight data storage formats are widely used for data exchange between applications, with database tables being the primary source of data for inter-system interactions. When a data query request is received from an application, the system first retrieves data from the database table based on the query conditions in the request. Then, the retrieved data is converted into JSON format and returned as the query result.

[0003] However, when the structure of the data table changes or the JSON format changes, the code for data querying and format conversion needs to be adjusted accordingly, which is inflexible, time-consuming, labor-intensive, and inefficient. Summary of the Invention

[0004] This invention provides a data query method, apparatus, device, system, and storage medium to solve the problems of poor flexibility and low efficiency caused by the need to adapt and adjust data query and format conversion code when the structure or JSON format of a data table changes in the prior art.

[0005] In a first aspect, embodiments of the present invention provide a data query method, including:

[0006] In response to receiving a data query request, the system obtains definition information of a preset lightweight data storage format; wherein, the definition information includes at least one model import attribute information and at least one model definition information, the model import attribute information is used to specify the imported data model, and the model definition information is used to specify the data table corresponding to the data model;

[0007] The definition information is parsed, and when the model-introduced attribute information is parsed, the model definition information of the data model specified by the model-introduced attribute information is obtained; a query operation is performed on the data table specified by the obtained model definition information.

[0008] The query results are obtained in a lightweight data storage format based on the query results.

[0009] Secondly, embodiments of the present invention also provide a data query device, the device comprising:

[0010] The information acquisition module is used to respond to a received data query request and acquire definition information of a preset lightweight data storage format; wherein, the definition information includes at least one model import attribute information and at least one model definition information, the model import attribute information is used to specify the imported data model, and the model definition information is used to specify the data table corresponding to the data model;

[0011] The information parsing module is used to parse the definition information. When the model-introduced attribute information is parsed, the module obtains the model definition information of the data model specified by the model-introduced attribute information and performs a query operation on the data table specified by the obtained model definition information.

[0012] The result retrieval module is used to obtain query result data in a lightweight data storage format based on the query results.

[0013] Thirdly, embodiments of the present invention also provide an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the data query method as described in any of the embodiments of the present invention.

[0014] Fourthly, embodiments of the present invention also provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the data query method as described in any of the embodiments of the present invention.

[0015] Fifthly, embodiments of the present invention also provide a computer program product, including a computer program that, when executed by a processor, implements the data query method as described in any of the embodiments of the present invention.

[0016] In the technical solution provided by this invention, in response to receiving a data query request, definition information of a preset lightweight data storage format is obtained. The definition information includes at least one model import attribute and at least one model definition. The model import attribute specifies the imported data model, and the model definition specifies the data table corresponding to the data model. The definition information is parsed, and when the model import attribute is parsed, the model definition information of the data model specified by the model import attribute is obtained. A query operation is performed on the data table specified by the obtained model definition information. Based on the query results, query result data in the lightweight data storage format is obtained. That is, in this invention, by obtaining and parsing the definition information of the preset lightweight data storage format, the database can be accessed and data assembled autonomously according to the definition information, improving data query efficiency. When the structure of the data table changes or the JSON format changes, only the definition information of the lightweight data storage format needs to be adjusted, without needing to adjust the data access and assembly code, providing greater flexibility and saving the manpower cost required for code adjustment. Attached Figure Description

[0017] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0018] Figure 1 This is a flowchart of a data query method provided in Embodiment 1 of the present invention;

[0019] Figure 2 This is a flowchart illustrating the parsing of definition information in a data query method provided in Embodiment 2 of the present invention;

[0020] Figure 3 This is a flowchart illustrating the parsing of definition information in another data query method provided in Embodiment 3 of the present invention;

[0021] Figure 4 This is a schematic diagram of the structure of a data query device provided in Embodiment 4 of the present invention;

[0022] Figure 5 This is a schematic diagram of the structure of an electronic device provided in Embodiment 5 of the present invention. Detailed Implementation

[0023] The present invention will now be described in further detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and not intended to limit it. Furthermore, it should be noted that, for ease of description, the accompanying drawings show only the parts relevant to the present invention, and not all of the structures.

[0024] It should be noted that similar reference numerals and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. Furthermore, in the description of this invention, terms such as "first," "second," etc., are used only for distinguishing descriptions and should not be construed as indicating or implying relative importance. The acquisition, storage, use, and processing of data in the technical solutions of this application all comply with the relevant provisions of national laws and regulations.

[0025] Example 1

[0026] Figure 1 This is a flowchart illustrating a data query method provided in Embodiment 1 of the present invention. This embodiment defines a JSON format, allowing applications to autonomously access the database, assemble data, and convert it into JSON format. This method can be executed by the data query device in this embodiment, which can be implemented in software and / or hardware, such as... Figure 1 As shown, the method specifically includes the following steps:

[0027] S110, in response to receiving a data query request, obtain the definition information of a preset lightweight data storage format; wherein, the definition information includes at least one model import attribute information and at least one model definition information, the model import attribute information is used to specify the imported data model, and the model definition information is used to specify the data table corresponding to the data model.

[0028] Among them, a data query request is a request information for finding target data from one or more data tables according to specific needs.

[0029] In this embodiment of the solution, optionally, in response to receiving a data query request, obtaining preset lightweight data storage structure information includes: in response to receiving a data query request through a service interface, obtaining lightweight data storage structure information pre-set for the service interface.

[0030] The service interface is used to enable information exchange across different systems and provides an entry point for this exchange. Different lightweight data storage structures are configured for different service interfaces. In this embodiment, the lightweight data storage format may optionally be JSON. JSON uses a text format completely independent of programming languages ​​to store and represent data, making it easy to read and write, as well as easy for machines to parse and generate. The JSON definition information includes at least one model-introduced attribute and at least one model definition. The model definition information specifies the data table corresponding to the data model. The data model is an abstraction of data characteristics, and its content includes data structure, data operations, and data constraints. The data model provides an abstract framework for the information representation and operation of the database system. Specifically, the data table to be queried can be determined based on the model definition information. The model-introduced attribute information specifies the introduced data model. Furthermore, the data table introduced during the query process can be determined based on the model-introduced attribute information.

[0031] For example, here is a summary of the tasks completed by the marketing department of a company, and its field content is shown in Table 1 below:

[0032] Field Item Name Chinese name MAKET_REPORT Marketing Department Information --TASK Task Information ----TA_ID Task Number ----BE_DT start date ----END_DT End Date ----PER Main person in charge ----EST_COST Task budget cost ----TR_COST Actual cost of the task ----EST_INC Expected Revenue from the Task ----TR_INC Actual income from the task ----CUS Customer Information ------CUS_TY Customer types ------CUS_NO Customer number

[0033] Table 1

[0034] Among them, MAKET_REPORT contains marketing department information, and its corresponding data tables are shown in Tables 2 and 3 below:

[0035]

[0036] Table 2

[0037]

[0038] Table 3

[0039] Assuming the query request is to retrieve all information with the primary key 'A', the JSON definition information obtained based on the query request is as follows:

[0040] Introducing a data model: Task information

[0041] Data model definition

[0042] Data model identifier: Task information

[0043] Table name: Task Information Table

[0044] Excluded fields: Code primary key, message identifier, system update timestamp

[0045] Query criteria field: Message Identifier

[0046] Association definition:

[0047] Other related data models: customer information data

[0048] Member fields corresponding to the query results of other related data models: Customer Information

[0049] Relationship type: One-to-many

[0050] The associated fields of the current data model: code primary key

[0051] Other related fields in the data model: Parent record number

[0052] Related data model identifier: Customer information data

[0053] Table Name: Customer Information Table

[0054] Query fields: Customer type, Information update date

[0055] Excluded fields: Code primary key, message identifier, system update timestamp

[0056] The attribute information of the JSON definition information mentioned above is described in Table 4 below:

[0057]

[0058] Table 4

[0059] The data types include object classes, array classes, numeric classes, constant character classes, and variable character classes. For example, the `import data model` directive specifies that the data model identified as "task information" should be imported. The data model defined in the data model definition section can be referenced by the imported data model.

[0060] The attributes defined in the data model definition are shown in Table 5 below:

[0061]

[0062] Table 5

[0063] In this context, the data model identifier in the data model definition represents the ID of the current data model. For example, the table name is the name of Table 2 (task information table). For example, the query fields represent the fields to be retrieved from the attribute information ("Customer Type" and "Customer Quantity" in Table 3). For example, the relationship definition defines the relationship between the current data model and other data models, i.e., the data model identified as "Customer Information Data". The values ​​of the query condition fields can be obtained based on the query conditions in the data query request. For example, the data model ID in the associated other data models is "Customer Information Data". The member field name in the member field corresponding to the query result of the associated other data models is "Customer Information", and this member field contains the query results for Table 3. The relationship types include one-to-many and one-to-one relationships. For example, from Tables 2 and 3, it can be seen that the relationship information between Tables 2 and 3 is the code primary key; therefore, the content of the relationship field of the current data model in this example is "Code Primary Key". The relationship field of other data models represents the relationship field to be queried ("Parent Record Number" in Table 3).

[0064] S120, parse the definition information, and when the model import attribute information is parsed, obtain the model definition information of the data model specified by the model import attribute information; perform a query operation on the data table specified by the obtained model definition information.

[0065] Specifically, after obtaining the preset JSON definition information, the definition information is parsed. This parsing includes parsing the JSON definition information from top to bottom according to the data query request. Specifically, if model import attribute information is found in the parsed JSON definition information, it indicates that data needs to be obtained by querying the data table defined in the imported data model. Further, the model definition information of the data model specified by the model import attribute information is obtained. For example, the aforementioned JSON definition information is parsed from top to bottom. When model import attribute information is found, the model definition information of the data model specified in the model import information (i.e., the data model identified as task information) is obtained; a query operation is then performed on the data table (Table 2) specified in the obtained model definition information.

[0066] S130, obtain query result data in a lightweight data storage format based on the query results.

[0067] The query results are obtained by parsing all definition information from top to bottom based on the data query request. For example, as mentioned earlier, the JSON definition information is parsed from top to bottom according to the query request to obtain the values ​​of each member field. Furthermore, the query result data in JSON format is obtained based on the values ​​of each member field.

[0068] The technical solution of this embodiment, in response to a received data query request, obtains the definition information of a preset lightweight data storage format. The definition information includes at least one model import attribute and at least one model definition. The model import attribute specifies the imported data model, and the model definition specifies the data table corresponding to the data model. The definition information is parsed; when the model import attribute is parsed, the model definition information of the data model specified by the model import attribute is obtained. A query operation is performed on the data table specified by the obtained model definition information. Based on the query results, query result data in the lightweight data storage format is obtained. In this embodiment, by obtaining and parsing the definition information of the preset lightweight data storage format, the database can be accessed and data assembled autonomously according to the definition information, improving data query efficiency. When the structure of the data table changes or the JSON format changes, only the definition information of the lightweight data storage format needs to be adjusted, without adjusting the data access and assembly code, providing high flexibility and saving the manpower cost required for code adjustment.

[0069] Example 2

[0070] Figure 2 This is a flowchart illustrating the parsing of definition information in a data query method according to Embodiment 2 of the present invention. This embodiment refines the steps for parsing definition information based on the above embodiment. For example... Figure 2 As shown, the method in this embodiment specifically includes the following steps:

[0071] S210, perform top-down parsing of the definition information. When parsing the attribute information of the member field, determine whether the attribute information contains model-imported attribute information. If so, obtain the model definition information of the data model specified by the model-imported attribute information.

[0072] In this embodiment, the optional model definition information includes: a data table identifier and query condition fields. The data table identifier includes the name of the data table, used to identify the data table, and is mandatory in the JSON definition information. For example, in the aforementioned JSON definition information, the data table identifier is "Task Information Table" under "Data Table Name," and the query condition field is "Message Identifier Number" under "Query Condition Fields." Member fields represent class attributes, defined in the format (data type member field name), such as (numeric code primary key), (string gender), etc. The attribute information of the member fields is parsed sequentially from top to bottom. When the attribute information of a member field contains model-imported attribute information, the data model imported by the model-imported attribute information is queried, and the data of the data table defined in the data model is used as the value of the member field. For example, the aforementioned JSON definition information is parsed from top to bottom, and when the attribute information of a member field (content in properties) is parsed, it is determined whether the attribute information contains model-imported attribute information. If the attribute information does not include model import attribute information, it means that this query request does not need to retrieve data from the data table defined in the imported data model. If the model attribute information includes model import attribute information, then the model definition information of the data model specified by the model import attribute information is retrieved. Of course, the attribute information of member fields and model import attribute information can be defined before importing model information, including data type, member field definition, and member field name, etc.

[0073] When the attribute information of a member field is not present in the definition information, the model-imported attribute information in the definition information is directly parsed. Then, the data information in the data table defined in the data model imported by the model-imported attribute information is directly queried, and the JSON query result data is obtained based on the query result of the data table.

[0074] S220, Based on the query condition information carried in the data query request, determine the value of the query condition field in the obtained model definition information.

[0075] Specifically, when a data query request is received through the service interface, the data query request contains query condition information. For example, the JSON definition information is as described above. Based on the query condition information, it can be determined that the query condition field in the JSON definition information is the message identifier number. Assuming the query condition information in the query request is that the message identifier number is A, then the value of the message identifier number in the JSON definition information is A.

[0076] S230: Based on the values ​​of the query condition fields and the data table identifiers in the obtained model definition information, generate a first data table query statement, and perform a query operation on the data table corresponding to the data table identifier based on the first data table query statement to obtain the first query result corresponding to the member fields.

[0077] The data table identifier includes the name of the data table, used to identify the data table, and is mandatory in the JSON definition information. The query statement is used to select data from the data table according to the query request. Further, a query operation is performed on the data table corresponding to the data table identifier based on the first data table query statement. For example, assuming the JSON definition information is as described above, the query condition field has the value A, and the data table corresponding to the data table identifier is the task information table (Table 2). Assume the content of the first data table (Table 2) query statement generated based on the query condition is to query the values ​​of all fields in Table 2. Further, performing a query operation on the data table (Table 2) corresponding to the data table identifier will obtain the values ​​of all fields in Table 2 corresponding to message identifier A, including task number, start date, end date, task budget cost, and task actual cost. And the values ​​of all fields corresponding to message identifier A are the first query result.

[0078] S240, Filter the field content in the first query result based on the fields to be retrieved and / or the fields to be excluded.

[0079] In this embodiment, the model definition information also includes fields to be acquired and / or fields to be excluded. The fields in the first query result can be filtered based on these fields. For example, the JSON definition information is as described above, and the first query result is the values ​​of all fields corresponding to message identifier A in Table 2. The fields to be excluded in the definition information are the code primary key, message identifier, and system timestamp values; therefore, the values ​​of the code primary key, message identifier, and system timestamp are deleted from the first query result.

[0080] The technical solution of this embodiment parses the definition information from top to bottom. When parsing the attribute information of member fields, it determines whether the attribute information includes model-imported attribute information. If so, it obtains the model definition information of the data model specified by the model-imported attribute information. Based on the query condition information carried in the data query request, it determines the value of the query condition field in the obtained model definition information. Based on the value of the query condition field and the data table identifier in the obtained model definition information, it generates a first data table query statement and executes a query operation on the data table corresponding to the data table identifier based on the first data table query statement to obtain the first query result corresponding to the member field. It then filters the field content in the obtained first query result according to the fields to be obtained and / or the fields to be excluded. The technical solution of this embodiment can obtain data from the data table according to the query request by parsing JSON definition information. This allows the application to autonomously access the database to assemble data based on the definition information, improving data query efficiency.

[0081] Example 3

[0082] Figure 3 This is a flowchart illustrating the parsing of definition information in another data query method provided in Embodiment 3 of the present invention. This method can be executed by the data query device in this embodiment of the invention, which can be implemented in software and / or hardware, such as... Figure 3 As shown, the method specifically includes the following steps:

[0083] S310, perform top-down parsing of the definition information. When parsing the attribute information of the member field, determine whether the attribute information contains model-imported attribute information. If so, obtain the model definition information of the data model specified by the model-imported attribute information.

[0084] S320, Based on the query condition information carried in the data query request, determine the value of the query condition field in the obtained model definition information.

[0085] S330: Based on the values ​​of the query condition fields and the data table identifiers in the obtained model definition information, generate a first data table query statement, and perform a query operation on the data table corresponding to the data table identifier based on the first data table query statement to obtain the first query result corresponding to the member fields.

[0086] S340, Filter the field content in the first query result based on the fields to be retrieved and / or the fields to be excluded.

[0087] S350, retrieve model definition information for other data models specified by the association information.

[0088] In this embodiment, the model definition information further includes association information. This association information specifies other data models associated with the current data model. Specifically, after performing a query operation on the data table specified by the obtained model definition information, the model definition information of the other data models specified by the association information is obtained. For example, the association information in the JSON definition information described above is the content of the association definition. Further, the definition information of the association definition is obtained, including the identifier of the associated other data models, the names of the member fields corresponding to the query results of the associated other data models, the association type, the associated fields of the current data model, and the associated fields of the other data models.

[0089] S360 executes a query operation on the data table specified by the model definition information of other data models to obtain the second query result corresponding to the member fields.

[0090] After obtaining the model definition information of other data models, a query operation is performed on the data table specified by the model definition information. Optionally, in this embodiment, performing a query operation on the data table specified by the model definition information of other data models includes: generating a second data table query statement based on the identifier and associated fields of the data table specified by the model definition information of other data models, and performing a query operation on the data table specified by the model definition information of other data models based on the second data table query statement.

[0091] For example, the JSON definition information is as described above. The data table specified in the model definition information of other data models (i.e., the data model identified as "Customer Information Data") is the Customer Information Data Table. Based on "Related Fields of the Current Data Model: Code Primary Key," we know that the related field of the current data model is the code primary key. Assume that in the first query result, when the message identifier number is A, the corresponding code primary key value is B. Further, from "Related Fields of Other Data Models: Parent Record Number," we know that the related field of the associated other data models is the parent record number. Assume that the query statement for generating the second data table (Table 3) based on the related fields is to query the values ​​of all fields corresponding to the parent record number in Table 3 when the value is B. Further, based on the second data table query statement, the query retrieves the values ​​of all fields corresponding to the parent record number in Table 3 when the value is B; this value is the second query result.

[0092] The above method is used to perform query operations on the data tables specified by the model definition information of other data models. By parsing the definition information of the preset lightweight data storage format, the database can be accessed and data assembled autonomously according to the definition information, thereby improving the data query efficiency.

[0093] S370, Based on the fields to be obtained and / or fields to be excluded in the model definition information of other data models, filter the field content in the obtained second query result.

[0094] In this embodiment, the model definition information for other data models includes fields to be acquired and / or fields to be excluded. Based on these fields, the field content in the second query result can be filtered. For example, as described above, the JSON definition information for the second query result is the values ​​of all fields in Table 3 corresponding to the parent record number being B. The fields to be excluded in the definition information are the code primary key, message identifier, and system timestamp. The fields to be acquired in the definition information are the customer type and customer quantity in Table 3.

[0095] S380, store the query result corresponding to the member field as the value (VALUE) in the MAP object created for the member field, where the key (KEY) of the MAP object is the identifier of the member field, and the MAP object serves as the VALUE of the MAP object corresponding to the parent member field of the member field.

[0096] Specifically, after obtaining the JSON definition information, the JSON definition is parsed from top to bottom. If the parsed data type is an object, a MAP is created as the root node object. The MAP object can store key-value pairs and remembers the original insertion order of the keys; any value (object or primitive value) can be used as a key or a value. During iteration, a MAP object loops according to the insertion order of its elements, returning an array of [key, value] after each iteration. Here, the KEY is the identifier of the member field, and the MAP object serves as the VALUE of the MAP object corresponding to the parent member field of that member field. Further, if member field definitions are found in the parsed definition information, the member fields defined in those definitions are traversed. Further, based on the data type of the member field in the member field definition, the corresponding MAP or LIST object is created. Specifically, if the member field's data type is an object, a MAP object is created as a member of the root node object. If the member field's data type is an array, a LIST object is created as a member of the root node object. Further, the query result corresponding to the member field is stored as the value VALUE in the MAP object created for that member field. This process continues until the entire definition information has been parsed.

[0097] S390 generates query result data in a lightweight data storage format based on each MAP object.

[0098] After storing the query results corresponding to the member fields as the value VALUE in the MAP objects created for the member fields, JSON query result data is generated based on each MAP object. Specifically, based on the data query request, the MAP object at each level is parsed to obtain the VALUE of each MAP object. For example, the JSON definition information is as described in section 1 above, and the query condition information is that the message identifier number is A. Based on the first and second query results described in the example above, the JSON query result data generated based on each MAP object is as follows (the values ​​of the queried member fields are exemplified using uppercase letters):

[0099] Marketing Department Information:

[0100] Task Information:

[0101] Task Number: C

[0102] Start Date: D

[0103] End Date: E

[0104] Key Person in Charge: F

[0105] Task budget cost: G

[0106] Actual cost of the task: H

[0107] Expected Revenue from the Task: I

[0108] Actual income from the task: J

[0109] Customer ID: K

[0110] Customer size: L

[0111] Customer Information:

[0112] Customer type: M

[0113] Number of customers: N

[0114] The technical solution of this embodiment parses the definition information from top to bottom. When the attribute information of the member field is parsed, it determines whether the attribute information contains model-introduced attribute information. If so, it obtains the model definition information of the data model specified by the model-introduced attribute information. Based on the query condition information carried in the data query request, it determines the value of the query condition field in the obtained model definition information. Based on the value of the query condition field and the data table identifier in the obtained model definition information, it generates a first data table query statement and performs a query operation on the data table corresponding to the data table identifier based on the first data table query statement to obtain the first query result corresponding to the member field. It filters the field content in the obtained first query result according to the fields to be obtained and / or the fields to be excluded. It obtains other data specified by the association relationship information. The model defines the data table in the model definition information of other data models and performs a query operation on the data table specified by the model definition information of other data models to obtain the second query result corresponding to the member fields. Based on the fields to be acquired and / or fields to be excluded in the model definition information of other data models, the field content in the obtained second query result is filtered. The query result corresponding to the member field is stored as the value VALUE in a MAP object created for the member field, where the key KEY of the MAP object is the identifier of the member field, and the MAP object serves as the VALUE of the MAP object corresponding to the parent member field of the member field. Query result data in a lightweight data storage format is generated based on each MAP object. In other words, in this embodiment of the invention, by parsing and obtaining the definition information of the preset lightweight data storage format, the database can be accessed and data assembled autonomously according to the definition information, improving data query efficiency. When the structure of the data table changes or the JSON format changes, only the definition information of the lightweight data storage format needs to be adjusted, without needing to adjust the data access and assembly code, which is highly flexible and saves the manpower cost required for code adjustment.

[0115] Example 4

[0116] Figure 4 This is a schematic diagram of a data query device provided in Embodiment 4 of the present invention. This embodiment defines a JSON format, allowing applications to autonomously access a database to assemble and convert data into JSON format based on the JSON format definition. This device can be implemented using software and / or hardware, and can be integrated into any device that provides data query functionality, such as… Figure 4 As shown, the data query device specifically includes:

[0117] The information acquisition module 410 is used to acquire definition information of a preset lightweight data storage format in response to receiving a data query request; wherein, the definition information includes at least one model import attribute information and at least one model definition information, the model import attribute information is used to specify the imported data model, and the model definition information is used to specify the data table corresponding to the data model;

[0118] The information parsing module 420 is used to parse the definition information. When the model-introduced attribute information is parsed, the module obtains the model definition information of the data model specified by the model-introduced attribute information and performs a query operation on the data table specified by the obtained model definition information.

[0119] The result acquisition module 430 is used to obtain query result data in a lightweight data storage format based on the query results.

[0120] Optionally, the information parsing module 420 specifically includes:

[0121] The attribute information determination unit is used to parse the definition information from top to bottom. When parsing the attribute information of the member field, it determines whether the attribute information contains model-introduced attribute information. If so, it obtains the model definition information of the data model specified by the model-introduced attribute information.

[0122] Optionally, the model definition information includes: data table identifier and query condition fields;

[0123] The attribute information determination unit is specifically used for:

[0124] Based on the query condition information carried in the data query request, determine the value of the query condition field in the obtained model definition information;

[0125] Based on the values ​​of the query condition fields and the data table identifiers in the obtained model definition information, a first data table query statement is generated, and a query operation is performed on the data table corresponding to the data table identifier based on the first data table query statement to obtain the first query result corresponding to the member field.

[0126] Optionally, the model definition information may also include fields to be acquired and / or fields to be excluded;

[0127] The attribute information determination unit is also used for:

[0128] The field content in the first query result is filtered according to the fields to be obtained and / or the fields to be excluded.

[0129] Optionally, the model definition information may also include association information, which is used to specify other data models associated with the current data model;

[0130] The attribute information determination unit is also used for:

[0131] After performing a query operation on the data table specified by the obtained model definition information, obtain the model definition information of the other data models specified by the association information;

[0132] Perform a query operation on the data table specified by the model definition information of the other data models to obtain the second query result corresponding to the member fields.

[0133] Optionally, the association information is also used to specify the association fields between the current data model and the other data models;

[0134] Optionally, the attribute information determining unit is further configured to:

[0135] Based on the identifier of the data table specified by the model definition information of the other data model and the associated field, a second data table query statement is generated, and a query operation is performed on the data table specified by the model definition information of the other data model based on the second data table query statement.

[0136] Optionally, the attribute information determining unit is further configured to:

[0137] Based on the fields to be acquired and / or fields to be excluded in the model definition information of the other data models, the field content in the obtained second query result is filtered.

[0138] Optionally, obtaining the query result data in a lightweight data storage format based on the query results includes:

[0139] The query result corresponding to the member field is stored as the value VALUE in the MAP object created for the member field, wherein the key KEY of the MAP object is the identifier of the member field, and the MAP object serves as the VALUE of the MAP object corresponding to the parent member field of the member field.

[0140] Query results are generated based on each MAP object in a lightweight data storage format.

[0141] Optionally, the step of obtaining preset lightweight data storage structure information in response to receiving a data query request includes:

[0142] In response to receiving a data query request through the service interface, obtain the lightweight data storage structure information that has been pre-set for the service interface.

[0143] Optionally, the lightweight data storage format is JSON.

[0144] The above-described products can perform the methods provided in any embodiment of the present invention, and have the corresponding functional modules and beneficial effects for performing the methods.

[0145] Example 5

[0146] Figure 5 This is a schematic diagram of the structure of an electronic device provided in Embodiment 5 of the present invention. Figure 5 A block diagram is shown of an exemplary electronic device 12 suitable for implementing embodiments of the present invention. Figure 5 The electronic device 12 shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of the present invention.

[0147] like Figure 5 As shown, the electronic device 12 is represented in the form of a general-purpose computing device. The components of the electronic device 12 may include, but are not limited to: one or more processors or processing units 16, system memory 28, and bus 18 connecting different system components (including system memory 28 and processing unit 16).

[0148] Bus 18 represents one or more of several bus architectures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration port, a processor, or a local bus using any of the various bus architectures. For example, these architectures include, but are not limited to, the Industry Standard Architecture (ISA) bus, the Micro Channel Architecture (MAC) bus, the Enhanced ISA bus, the Video Electronics Standards Association (VESA) local bus, and the Peripheral Component Interconnect (PCI) bus.

[0149] Electronic device 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by electronic device 12, including volatile and non-volatile media, removable and non-removable media.

[0150] System memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. Electronic device 12 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, storage system 34 may be used to read and write non-removable, non-volatile magnetic media (… Figure 5 Not shown; usually referred to as a "hard drive"). Although Figure 5Not shown, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk") and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to bus 18 via one or more data media interfaces. Memory 28 may include at least one program product having a set (e.g., at least one) of program modules configured to perform the functions of the embodiments of the present invention.

[0151] A program / utility 40 having a set (at least one) of program modules 42 may be stored, for example, in memory 28. Such program modules 42 include—but are not limited to—an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include an implementation of a network environment. Program modules 42 typically perform the functions and / or methods described in the embodiments of the present invention.

[0152] Electronic device 12 can also communicate with one or more external devices 14 (e.g., keyboard, pointing device, display 24, etc.), and with one or more devices that enable a user to interact with electronic device 12, and / or with any device that enables electronic device 12 to communicate with one or more other computing devices (e.g., network card, modem, etc.). This communication can be performed via input / output (I / O) interface 22. Furthermore, in this embodiment, electronic device 12 and display 24 are not separate entities, but are embedded in a mirror, so that when the display surface of display 24 is not displayed, the display surface of display 24 and the mirror surface visually blend together. Additionally, electronic device 12 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 20. As shown, network adapter 20 communicates with other modules of electronic device 12 via bus 18. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with electronic device 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0153] The processing unit 16 executes various functional applications and data processing by running programs stored in the system memory 28, such as implementing a data query method provided in this embodiment of the invention: in response to receiving a data query request, it obtains definition information of a preset lightweight data storage format; wherein, the definition information includes at least one model introduction attribute information and at least one model definition information, the model introduction attribute information is used to specify the introduced data model, and the model definition information is used to specify the data table corresponding to the data model; the definition information is parsed, and when the model introduction attribute information is parsed, the model definition information of the data model specified by the model introduction attribute information is obtained; a query operation is performed on the data table specified by the obtained model definition information; and query result data in a lightweight data storage format is obtained based on the query result.

[0154] Example 6

[0155] This invention provides a computer-readable storage medium storing a computer program. When executed by a processor, this program implements a data query method as provided in all embodiments of this invention: In response to receiving a data query request, it obtains definition information of a preset lightweight data storage format; wherein the definition information includes at least one model introduction attribute information and at least one model definition information, the model introduction attribute information being used to specify the introduced data model, and the model definition information being used to specify the data table corresponding to the data model; it parses the definition information, and when the model introduction attribute information is parsed, it obtains the model definition information of the data model specified by the model introduction attribute information; it performs a query operation on the data table specified by the obtained model definition information; and it obtains query result data in a lightweight data storage format based on the query result. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or any combination thereof. More specific examples of computer-readable storage media (a non-exhaustive list) include: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing. In this document, a computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in connection with an instruction execution system, apparatus, or device.

[0156] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, capable of sending, propagating, or transmitting programs for use by or in connection with an instruction execution system, apparatus, or device.

[0157] Program code contained on a computer-readable medium may be transmitted using any suitable medium, including but not limited to wireless, wire, optical fiber, RF, etc., or any suitable combination thereof.

[0158] Example 7

[0159] Embodiment 7 of the present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the data query method provided in any embodiment of this application: in response to receiving a data query request, obtaining definition information of a preset lightweight data storage format; wherein, the definition information includes at least one model introduction attribute information and at least one model definition information, the model introduction attribute information being used to specify the introduced data model, and the model definition information being used to specify the data table corresponding to the data model; parsing the definition information, and when the model introduction attribute information is parsed, obtaining the model definition information of the data model specified by the model introduction attribute information; performing a query operation on the data table specified by the obtained model definition information; and obtaining query result data in a lightweight data storage format based on the query result. In the implementation of the computer program product, computer program code for executing the operations of the present invention can be written in one or more programming languages ​​or a combination thereof. Programming languages ​​include object-oriented programming languages ​​such as Java, Smalltalk, and C++, as well as conventional procedural programming languages ​​such as C or similar programming languages. The program code can execute entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or it can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0160] Note that the above description is merely a preferred embodiment of the present invention and the technical principles employed. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and various obvious changes, readjustments, and substitutions can be made without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in detail through the above embodiments, the present invention is not limited to the above embodiments, and may include many other equivalent embodiments without departing from the concept of the present invention, the scope of which is determined by the scope of the appended claims.

Claims

1. A data query method, characterized in that, include: In response to receiving a data query request, the system obtains definition information of a preset lightweight data storage format; wherein, the definition information includes at least one model import attribute information and at least one model definition information, the model import attribute information is used to specify the imported data model, and the model definition information is used to specify the data table corresponding to the data model; The definition information is parsed from top to bottom. When the attribute information of the member field is parsed, it is determined whether the attribute information contains model-introduced attribute information. If so, the model definition information of the data model specified by the model-introduced attribute information is obtained. The model definition information includes: data table identifier and query condition fields. The data of the data table of the data model specified by the model definition information is used as the value of the member field. A query operation is performed on the data table specified by the obtained model definition information, including: obtaining the first query result corresponding to the member field according to the query condition information carried in the data query request. The model definition information also includes association information, which is used to specify other data models associated with the current data model. After performing a query operation on the data table specified by the obtained model definition information, the method further includes: obtaining the model definition information of the other data models specified by the association information; performing a query operation on the data table specified by the model definition information of the other data models to obtain the second query result corresponding to the member field. The query results corresponding to the member fields are stored as the value VALUE in the MAP object created for the member fields, wherein the key KEY of the MAP object is the identifier of the member field, and the MAP object serves as the VALUE of the MAP object corresponding to the parent member field of the member field; query result data in a lightweight data storage format is generated based on each MAP object; the query results include the first query result and the second query result; When the attribute information of the member field is not present in the model definition information, the model introduction attribute information in the model definition information is directly parsed, the data information in the data table defined in the data model introduced in the model introduction attribute information is queried, the query result is obtained, and the query result data is obtained based on the query result.

2. The method according to claim 1, characterized in that, The step of performing a query operation on the data table specified by the obtained model definition information includes: Based on the query condition information carried in the data query request, determine the value of the query condition field in the obtained model definition information; Based on the values ​​of the query condition fields and the data table identifiers in the obtained model definition information, a first data table query statement is generated, and a query operation is performed on the data table corresponding to the data table identifier based on the first data table query statement to obtain the first query result corresponding to the member field.

3. The method according to claim 2, characterized in that, The model definition information also includes fields to be acquired and / or fields to be excluded, and the method further includes: The field content in the first query result is filtered according to the fields to be obtained and / or the fields to be excluded.

4. The method according to claim 3, characterized in that, The association information is also used to specify the association fields between the current data model and the other data models; The query operation performed on the data table specified by the model definition information of the other data models includes: Based on the identifier of the data table specified by the model definition information of the other data model and the associated field, a second data table query statement is generated, and a query operation is performed on the data table specified by the model definition information of the other data model based on the second data table query statement.

5. The method according to claim 3, characterized in that, The method further includes: Based on the fields to be acquired and / or fields to be excluded in the model definition information of the other data models, the field content in the obtained second query result is filtered.

6. The method according to any one of claims 1-4, characterized in that, In response to receiving a data query request, the system retrieves information about a preset lightweight data storage structure, including: In response to receiving a data query request through the service interface, obtain the lightweight data storage structure information that has been pre-set for the service interface.

7. The method according to any one of claims 1-4, characterized in that, The lightweight data storage format is JSON.

8. A data query device, characterized in that, include: The information acquisition module is used to respond to a received data query request and acquire definition information of a preset lightweight data storage format; wherein, the definition information includes at least one model import attribute information and at least one model definition information, the model import attribute information is used to specify the imported data model, and the model definition information is used to specify the data table corresponding to the data model; An information parsing module is used to parse the definition information. When the model-introduced attribute information is parsed, the module obtains the model definition information of the data model specified by the model-introduced attribute information. A query operation is performed on the data table specified by the obtained model definition information. The information parsing module includes an attribute information determination unit, used to parse the definition information from top to bottom. When the attribute information of a member field is parsed, the unit determines whether the attribute information contains model-introduced attribute information. If so, the module obtains the model definition information of the data model specified by the model-introduced attribute information. The model definition information includes a data table identifier and a query condition field. The data of the data table of the data model specified by the model definition information is used as the value of the member field. A query operation is performed on the data table specified by the obtained model definition information, including obtaining a first query result corresponding to the member field based on the query condition information carried in the data query request. The model definition information also includes association information, which is used to specify other data models associated with the current data model; after performing a query operation on the data table specified by the obtained model definition information, the method further includes: obtaining the model definition information of the other data models specified by the association information; performing a query operation on the data table specified by the model definition information of the other data models to obtain the second query result corresponding to the member field; The result acquisition module is used to store the query result corresponding to the member field as the value VALUE in a MAP object created for the member field, wherein the key KEY of the MAP object is the identifier of the member field, and the MAP object serves as the VALUE of the MAP object corresponding to the parent member field of the member field; and to generate query result data in a lightweight data storage format based on each MAP object; the query result includes the first query result and the second query result; When the attribute information of the member field is not present in the model definition information, the model introduction attribute information in the model definition information is directly parsed, the data information in the data table defined in the data model introduced in the model introduction attribute information is queried, the query result is obtained, and the query result data is obtained based on the query result.

9. An electronic device, characterized in that, The system includes a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that the processor, when executing the computer program, implements the data query method as described in any one of claims 1-7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the data query method as described in any one of claims 1-7.

11. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the data query method as described in any one of claims 1-7.

Citation Information

Patent Citations

  • Data backup method and device based on data models

    CN103678396A

  • A database access method and apparatus

    CN109284326A

  • Data query method and system and storage medium

    CN113986963A