Query method and device based on Chinese logical expression
By using a query method and device based on Chinese logical expressions, the query problem for ordinary users in blockchain scenarios has been solved, enabling block information queries without the need for English expressions, simplifying the operation process and improving query efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-06-05
- Publication Date
- 2026-03-24
AI Technical Summary
Existing SQL query methods in blockchain scenarios make it difficult for ordinary users to perform block and contract queries, especially when querying and counting blockchain data entries, due to the use of English characters and expressions.
A query method and apparatus based on Chinese logical expressions are provided. By receiving Chinese query requests from users, generating Chinese logical expressions, and performing queries using a pre-built block information table, the query results are returned, simplifying the query process.
It enables users without a background in traditional SQL query language to easily query block information, simplifies query statements, improves query efficiency, and ensures that query conditions are strictly processed according to expressions without manual intervention.
Smart Images

Figure HDA0003102308140000011 
Figure HDA0003102308140000012 
Figure HDA0003102308140000021
Abstract
Description
Technical Field
[0001] This application relates to the fields of data querying and blockchain, and in particular to a query method and apparatus based on Chinese logical expressions. Background Technology
[0002] In today's information-explosive era, data is growing at an unprecedented rate. After being processed and stored in a database, structured data needs to be queried and retrieved using appropriate machine languages, such as SQL, before it can realize its value.
[0003] Existing SQL query methods typically use English characters and expressions to compose query statements. In blockchain use cases, due to the frequent on-chain business, general users do not have much of a foundation in learning traditional SQL query languages. Therefore, they face greater difficulties in tasks such as block queries and contract queries, and find it even more difficult to adapt when querying blockchain data entries and making statistics. Summary of the Invention
[0004] To address the aforementioned shortcomings or drawbacks, this invention provides a query method, apparatus, computer device, and storage medium based on Chinese logical expressions. The embodiments of this invention enable users without a foundation in learning traditional SQL query language to easily query block information.
[0005] According to a first aspect, the present invention provides a query method based on Chinese logical expressions. In one embodiment, the method includes:
[0006] Receive query requests from users that carry Chinese query information;
[0007] Generate a Chinese logical expression based on the Chinese query information carried in the query request;
[0008] The query results are obtained by querying the pre-built block information table based on the Chinese logical expression.
[0009] The query results are returned to the user.
[0010] In one embodiment, before receiving a query request carrying Chinese query information from a user, the method further includes:
[0011] Read all block fields in each block on the blockchain, as well as the field values corresponding to each block field;
[0012] Convert each block field in each block into a Chinese variable, and assign the field value corresponding to each block field to the corresponding Chinese variable.
[0013] A block information table is constructed based on the Chinese variables and their values corresponding to the block fields in each block.
[0014] In one embodiment, a pre-built block information table is queried based on a Chinese logical expression to obtain the query results, including:
[0015] Parse the Chinese logical expression to obtain the field parameters it contains;
[0016] Substitute the Chinese variables associated with the field parameters and their values into the Chinese logical expression, and calculate the result of the Chinese logical expression;
[0017] The results are obtained by querying the pre-built block information table based on the calculated results.
[0018] In one embodiment, parsing a Chinese logical expression includes:
[0019] Check if Chinese logical expressions exist in the cache;
[0020] When it is determined that a Chinese logical expression exists in the cache, the query result matching the Chinese logical expression is retrieved from the cache and returned to the user.
[0021] If it is determined that there are no Chinese logical expressions in the cache, the Chinese logical expressions are parsed.
[0022] In one embodiment, the logical relations of a Chinese logical expression include yes, no, and, as well as or.
[0023] According to a second aspect, the present invention provides a query device based on Chinese logical expressions. In one embodiment, the device includes:
[0024] The query request receiving module is used to receive query requests from the user terminal that carry Chinese query information;
[0025] The expression generation module is used to generate Chinese logical expressions based on the Chinese query information carried in the query request.
[0026] The query module is used to query a pre-built block information table based on Chinese logical expressions and obtain the query results;
[0027] The query results return module is used to return the query results to the user.
[0028] In one embodiment, the query device based on Chinese logical expressions further includes:
[0029] The reading module is used to read all block fields in each block on the blockchain, as well as the field values corresponding to each block field.
[0030] The field variableization module is used to convert each block field in each block into Chinese variables, and assign the field value corresponding to each block field to the corresponding Chinese variable.
[0031] The table construction module is used to construct a block information table based on the Chinese variables and their values corresponding to the block fields in each block.
[0032] In one embodiment, the query module includes:
[0033] The parsing submodule is used to parse Chinese logical expressions to obtain the field parameters they contain;
[0034] The calculation submodule is used to substitute the Chinese variables associated with the field parameters and their values into a Chinese logical expression, and to calculate the result of the Chinese logical expression;
[0035] The query submodule is used to query the pre-built block information table based on the calculated results and obtain the query results.
[0036] In one embodiment, when parsing Chinese logical expressions, the parsing submodule specifically checks whether a Chinese logical expression exists in the cache; if it determines that a Chinese logical expression exists in the cache, it retrieves the query result matching the Chinese logical expression from the cache and returns it to the user; if it determines that a Chinese logical expression does not exist in the cache, it parses the Chinese logical expression.
[0037] In one embodiment, the logical relations of a Chinese logical expression include yes, no, and, as well as or.
[0038] In this embodiment of the invention, a query request carrying Chinese query information is received from a user client; a Chinese logical expression is generated based on the Chinese query information carried in the query request; a pre-built block information table is queried based on the Chinese logical expression to obtain the query result; and the query result is returned to the user client. This embodiment of the invention enables users without a foundation in traditional SQL query language to easily query block information. Attached Figure Description
[0039] Figure 1 This is an application environment diagram of a query method based on Chinese logical expressions in one embodiment;
[0040] Figure 2 This is a flowchart illustrating a query method based on Chinese logical expressions in one embodiment;
[0041] Figure 3 This is a structural block diagram of a query device based on Chinese logical expressions in one embodiment;
[0042] Figure 4 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0043] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0044] This invention provides a query method based on Chinese logical expressions. In one embodiment, this query method based on Chinese logical expressions can be applied to, for example... Figure 1 The application environment shown.
[0045] When a user needs to query block information in the blockchain (such as information within the block, smart contracts, etc.), they can send a query request to the query server 20 via network 30 using client 10. The query server 20 can then respond to the query request by generating a Chinese logical expression based on the request, retrieving matching block information based on this expression, and returning it to client 10. Client 10 can then display the query results returned by the query server to the user. When sending a query request through client 10, the user can directly edit the expression using Chinese characters, allowing users without prior knowledge of traditional SQL query languages to easily query block information. Client 10 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, and desktop computers. The query server 20 can be implemented using a standalone server or a server cluster consisting of multiple servers.
[0046] This embodiment provides a query method based on Chinese logical expressions, including, for example: Figure 2 The steps shown below are applied to this method. Figure 1 The following explanation uses the query server as an example.
[0047] S110: Receive a query request from the user terminal carrying Chinese query information;
[0048] S120: Generate a Chinese logical expression based on the Chinese query information carried in the query request;
[0049] S130: Query the pre-built block information table based on the Chinese logical expression to obtain the query result;
[0050] S140: Return the query results to the user.
[0051] In this embodiment of the invention, the query server receives a query request from the user client carrying Chinese query information; generates a Chinese logical expression based on the Chinese query information carried in the query request; queries a pre-built block information table based on the Chinese logical expression to obtain the query result; and returns the query result to the user client, thereby enabling users without a foundation in learning traditional SQL query language to easily query block information.
[0052] Furthermore, in this embodiment, the query statement can be greatly simplified, logical expressions can be edited entirely in Chinese, the query content can be expressed using a single Chinese parameter, and the query conditions can be expressed using programming language expressions. Therefore, it is convenient and simple to use. The fields (variables) of each block, ascending and descending order, and automatic encryption and decryption within the block do not require manual intervention, and the query conditions are strictly processed according to the expression.
[0053] The following is a detailed description of the query method based on Chinese logical expressions.
[0054] This embodiment provides a web page for the user, where the user can edit logical expressions. After editing the logical expressions, the user can instruct the client to send a query request to the query server. The client will then obtain the information edited by the user on the page to generate the relevant parameter information (i.e., Chinese query information) in the query request. Notably, the user can use Chinese characters to edit the logical expressions, rather than using English characters to edit English expressions.
[0055] When the query server receives a query request from the user, it retrieves the Chinese query information carried in the request and constructs a Chinese logical expression based on this information. Once the Chinese logical expression is constructed, it can be executed to retrieve matching information from a pre-built block information table. The logical relationships that the user can use when editing the Chinese logical expression include "yes," "no," "and," and "or."
[0056] The query server retrieves the query results from a pre-built block information table based on Chinese logical expressions. This process includes: parsing the Chinese logical expressions to obtain the included field parameters; substituting the associated Chinese variables and their values into the Chinese logical expressions and calculating the results; and then querying the pre-built block information table based on the calculated results. Specifically, the query server parses the Chinese logical expressions by: checking if the expressions exist in the cache; if they do, retrieving the query results from the cache and returning them to the user; and parsing the expressions if they do not exist in the cache. When parsing the Chinese logical expressions, the query server first checks if the same query exists in the cache. If so, it directly retrieves the pre-cached query results, avoiding duplicate queries and improving query efficiency.
[0057] Furthermore, before receiving a query request from a user containing Chinese query information, the query server also includes:
[0058] Read all block fields in each block of the blockchain, as well as the field values corresponding to each block field; convert each block field in each block into Chinese variables, and assign the field values corresponding to each block field to the corresponding Chinese variables; construct a block information table based on the Chinese variables corresponding to each block field in each block and their values.
[0059] The query server needs to variableize the block fields in each block on the blockchain, and then translate the variable block elements into Chinese. Variableizing block fields refers to converting the block fields from characters represented in other languages (such as English letters) into Chinese variables (specifically, variables in the code), and assigning the values of the block fields to their corresponding Chinese variables. These Chinese variables can be divided into data variables and text variables. The block fields in a block are also called block elements, such as block number, hash value, and block height. It should be noted that the type and number of block elements contained in a block may vary in different application scenarios; this embodiment does not limit this.
[0060] The following two examples illustrate the above method of variableizing block fields.
[0061] In one example, suppose a block contains a block field "block_height" with a value of 10. Then, the block field and its value can be variableized in the program. That is, the block field "block_height" can be defined as a numeric variable, i.e., "numeric variable block height". Then, the Chinese variable "block height" can be assigned a value, i.e., "block height = 10".
[0062] In another example, suppose a block contains a block field "block_hash" with a value of 10894037564873748. In this case, the block field and its value can be variable in the program. That is, the block field "block_hash" can be defined as a Chinese variable, i.e., "Chinese variable block hash value". Then, the Chinese variable "block hash value" can be assigned a value, i.e., "block hash value = 10894037564873748".
[0063] Furthermore, it is necessary to list the block fields and their values for each block, then construct a two-dimensional table to form a database. The relevant fields in the database are entirely in Chinese, so the field parameters in the SQL query statements are filtered using Chinese characters.
[0064] Figure 2 This is a flowchart illustrating a query method based on Chinese logical expressions in one embodiment. It should be understood that, although... Figure 2 The steps in the flowchart are shown sequentially as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order in which these steps are executed, and they can be performed in other orders. Furthermore, Figure 2 At least some of the steps in the process may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least some of the sub-steps or stages of other steps.
[0065] Based on the same inventive concept, the present invention also provides a query device based on Chinese logical expressions. In one embodiment, such as... Figure 3 As shown, the query device based on Chinese logical expressions includes the following modules:
[0066] The query request receiving module 110 is used to receive query requests from the user terminal that carry Chinese query information;
[0067] The expression generation module 120 is used to generate Chinese logical expressions based on the Chinese query information carried in the query request;
[0068] The query module 130 is used to query a pre-built block information table based on Chinese logical expressions and obtain query results;
[0069] The query result return module 140 is used to return the query results to the user.
[0070] The query device based on Chinese logical expressions provided by the embodiments of the present invention enables users without a foundation in learning traditional SQL query language to easily query block information.
[0071] In one embodiment, the query device based on Chinese logical expressions further includes:
[0072] The reading module is used to read all block fields in each block on the blockchain, as well as the field values corresponding to each block field.
[0073] The field variableization module is used to convert each block field in each block into Chinese variables, and assign the field value corresponding to each block field to the corresponding Chinese variable.
[0074] The table construction module is used to construct a block information table based on the Chinese variables and their values corresponding to the block fields in each block.
[0075] In one embodiment, the query module includes:
[0076] The parsing submodule is used to parse Chinese logical expressions to obtain the field parameters they contain;
[0077] The calculation submodule is used to substitute the Chinese variables associated with the field parameters and their values into a Chinese logical expression, and to calculate the result of the Chinese logical expression;
[0078] The query submodule is used to query the pre-built block information table based on the calculated results and obtain the query results.
[0079] In one embodiment, when parsing Chinese logical expressions, the parsing submodule specifically checks whether a Chinese logical expression exists in the cache; if it determines that a Chinese logical expression exists in the cache, it retrieves the query result matching the Chinese logical expression from the cache and returns it to the user; if it determines that a Chinese logical expression does not exist in the cache, it parses the Chinese logical expression.
[0080] In one embodiment, the logical relations of a Chinese logical expression include yes, no, and, as well as or.
[0081] Specific limitations regarding the query device based on Chinese logical expressions can be found in the limitations of the query method based on Chinese logical expressions above, and will not be repeated here. Each module in the aforementioned query device based on Chinese logical expressions can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in the computer device in hardware form, or stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0082] In one embodiment, a computer device is provided, the internal structure of which can be shown as follows: Figure 4 As shown, the computer device includes a processor, memory, network interface, and database connected via a system bus. The processor provides computing and control capabilities. The memory includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores the operating system, computer programs, and the database. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage medium. The database stores data such as block information; the specific data stored can be further defined in the above method embodiments. The network interface is used to communicate with external terminals via a network connection. When the computer program is executed by the processor, it implements a query method based on Chinese logical expressions.
[0083] Those skilled in the art will understand that Figure 4 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0084] Those skilled in the art will understand that implementing all or part of the processes in the above method embodiments can be accomplished by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0085] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0086] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.
Claims
1. A query method based on Chinese logical expressions, characterized in that, Read all block fields in each block of the blockchain, as well as the field values corresponding to each block field; convert each block field in each block into Chinese variables, and assign the field values corresponding to each block field to the corresponding Chinese variables; construct a block information table based on the Chinese variables corresponding to each block field in each block and their values. Receive query requests from users that carry Chinese query information; After determining that the user has completed editing the logical expression, the user terminal obtains the information edited by the user on the web page and generates the Chinese query information. The query content of the edit expression is represented using Chinese parameters, and the query conditions are expressed using programming language expressions; Generate a Chinese logical expression based on the Chinese query information carried in the query request; The Chinese logical expression is parsed to obtain the field parameters it contains; Substitute the Chinese variables and their values associated with the field parameters into the Chinese logical expression and calculate the result of the Chinese logical expression; then query the pre-built block information table based on the calculated result to obtain the query result; The query results are returned to the user's client.
2. The query method based on Chinese logical expressions as described in claim 1, characterized in that, Parsing the Chinese logical expression includes: Check if the Chinese logical expression exists in the cache; When it is determined that the Chinese logical expression exists in the cache, the query result matching the Chinese logical expression is retrieved from the cache and returned to the user client; If it is determined that the Chinese logical expression does not exist in the cache, the Chinese logical expression is parsed.
3. The query method based on Chinese logical expressions as described in claim 1, characterized in that, The logical relationships in the Chinese logical expressions include yes, no, and, as well as or.
4. A query device based on Chinese logical expressions, characterized in that, The device includes: The reading module is used to read all block fields in each block on the blockchain, as well as the field values corresponding to each block field. The field variableization module is used to convert each block field in each block into Chinese variables, and assign the field value corresponding to each block field to the corresponding Chinese variable. The table construction module is used to construct a block information table based on the Chinese variables and their values corresponding to the fields of each block in each block. The query request receiving module is used to receive query requests carrying Chinese query information from the user terminal; after determining that the user has completed editing the logical expression, the user terminal obtains the information edited by the user on the web page to generate the Chinese query information; the query content of the edited expression is represented by Chinese parameters, and the query conditions are expressed using programming language expressions; An expression generation module is used to generate Chinese logical expressions based on the Chinese query information carried in the query request. The query module includes: a parsing submodule, used to parse the Chinese logical expression to obtain the field parameters contained therein; a calculation submodule, used to substitute the Chinese variables associated with the field parameters and their values into the Chinese logical expression and calculate the result of the Chinese logical expression; and a query submodule, used to query from a pre-built block information table based on the calculated result to obtain the query result. The query result return module is used to return the query results to the user terminal.
5. The query device based on Chinese logical expressions as described in claim 4, characterized in that, When parsing the Chinese logical expression, the parsing submodule specifically checks whether the Chinese logical expression exists in the cache; if it determines that the Chinese logical expression exists in the cache, it retrieves the Chinese logical expression from the cache. The query results are retrieved and returned to the user client; if it is determined that the Chinese logical expression does not exist in the cache, the Chinese logical expression is parsed.
6. The query device based on Chinese logical expressions as described in claim 4, characterized in that, The logical relationships in the Chinese logical expressions include yes, no, and, as well as or.
Citation Information
Patent Citations
Data query method and device
CN106897280A
Voice inquiry method and device and electronic device
CN109542929A
Block chain-based data query method, apparatus and device and storage medium
CN109885583A
Data acquisition method, device and equipment and storage medium
CN111858658A
Calculation method and device based on Chinese expression, equipment and storage medium
CN112463819A