WO2020233367A1 - Procédé, appareil et dispositif d'interrogation et de stockage de données de chaînes de blocs, et support d'enregistrement - Google Patents

Procédé, appareil et dispositif d'interrogation et de stockage de données de chaînes de blocs, et support d'enregistrement Download PDF

Info

Publication number
WO2020233367A1
WO2020233367A1 PCT/CN2020/087585 CN2020087585W WO2020233367A1 WO 2020233367 A1 WO2020233367 A1 WO 2020233367A1 CN 2020087585 W CN2020087585 W CN 2020087585W WO 2020233367 A1 WO2020233367 A1 WO 2020233367A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
plan
query
blockchain
index
Prior art date
Application number
PCT/CN2020/087585
Other languages
English (en)
Chinese (zh)
Inventor
鲁铁华
Original Assignee
深圳壹账通智能科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 深圳壹账通智能科技有限公司 filed Critical 深圳壹账通智能科技有限公司
Publication of WO2020233367A1 publication Critical patent/WO2020233367A1/fr

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2228Indexing structures
    • G06F16/2246Trees, e.g. B+trees
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2458Special types of queries, e.g. statistical queries, fuzzy queries or distributed queries
    • G06F16/2471Distributed queries

Definitions

  • This application relates to the field of block structure improvement, in particular to blockchain data storage and query methods, devices, equipment and storage media.
  • Blockchain is an intelligent peer-to-peer network that uses distributed databases to identify, disseminate and record information. It is also called the Internet of Value.
  • Blockchain is essentially a decentralized database.
  • Blockchain Contains a list called blocks, which has a continuously growing and neatly arranged record. Each block contains a timestamp and a link to the previous block. The block chain makes the data immutable. Once recorded, the data in a block will be irreversible.
  • Blockchain distributed storage data is of key-value type. Although the bottom layer of blockchain technology also provides interfaces for data operations, these interfaces are relatively simple.
  • the transaction information stored in the block is basically The existence of the string form requires the application to frequently parse the data information of the string. It only supports querying the data stored on the chain by key, and does not support complex queries, which is inconvenient to use.
  • the main purpose of this application is to solve the problem of insufficient support of the blockchain for complex queries and low retrieval efficiency. At the same time, it solves the need to rewrite the data query and storage logic code when the data storage is changed from a relational database to a blockchain distributed database. , Leading to the problems of large development workload, long time-consuming and low development efficiency.
  • the first aspect of this application provides a blockchain data storage and query method, including: generating an index database; obtaining a target structured query language SQL statement, the target SQL statement being legal in compliance with SQL syntax rules Statement; parse the target SQL statement according to a preset algorithm to obtain an abstract syntax tree; generate a logical execution plan according to the abstract syntax tree, and the logical execution plan includes inserting a data plan, modifying a data plan, and querying a data plan; according to The logic generation plan and the index database perform read and write operations on the blockchain distributed database to obtain read and write results.
  • the blockchain distributed database is used to store and query data.
  • the second aspect of the present application provides a block chain data storage and query device, including: a first generating unit for generating an index database; an obtaining unit for obtaining a target structured query language SQL statement, the target SQL statement It is a legal statement that conforms to the SQL grammar rules; the parsing unit is used to parse the target SQL statement according to a preset algorithm to obtain an abstract syntax tree; the second generation unit is used to generate a logical execution plan according to the abstract syntax tree, The logic execution plan includes inserting data plans, modifying data plans, and querying data plans; a reading and writing unit is used to perform read and write operations on the blockchain distributed database according to the logic generation plan and the index database to obtain read and write operations As a result, the blockchain distributed database is used to store and query data.
  • a third aspect of the present application provides a blockchain data storage and query method and equipment, including: a memory and at least one processor, the memory stores instructions, and the memory and the at least one processor are interconnected by wires; The at least one processor invokes the instructions in the memory, so that the blockchain data storage and query device executes the methods described in the foregoing aspects.
  • the fourth aspect of the present application provides a computer-readable storage medium that stores instructions in the computer-readable storage medium, which when run on a computer, causes the computer to execute the methods described in the above aspects.
  • the fifth aspect of the present application provides a computer program product containing instructions, which when run on a computer, causes the computer to execute the methods described in the foregoing aspects.
  • the use of SQL statements is compatible with query and storage in the blockchain distributed database and the relational database, and the corresponding relationship between the index database and the blockchain distributed database is established to improve the area.
  • Retrieval efficiency of blockchain business information encapsulate the underlying interface of blockchain, use SQL statements and index databases to achieve data storage and query on the chain.
  • Figure 1 is a schematic diagram of an embodiment of a blockchain data storage and query method in an embodiment of the application
  • FIG. 2 is a schematic diagram of another embodiment of a blockchain data storage and query method in an embodiment of the application
  • Fig. 3 is a schematic diagram of an embodiment of a block chain data storage and query device in an embodiment of the application
  • Figure 4 is a schematic diagram of another embodiment of a blockchain data storage and query device in an embodiment of the present invention.
  • Fig. 5 is a schematic diagram of another embodiment of a blockchain data storage and query device in an embodiment of the application.
  • the embodiment of the application provides a blockchain data storage and query method, device, device, and storage medium.
  • the use of SQL statements is compatible with blockchain distributed databases and relationships.
  • Query and storage of type database improve the retrieval efficiency of blockchain business information by establishing the corresponding relationship between the index database and the blockchain distributed database, encapsulate the underlying interface of the blockchain, and use SQL statements and index databases to achieve data on the chain Storage and query, lower development threshold and improve development efficiency.
  • An embodiment of the blockchain data storage and query method in the embodiment of the present application includes:
  • the server generates an index database according to business requirements.
  • the index database is located in the data middleware of the blockchain.
  • the data middleware also provides a unified interface for accessing the underlying blockchain of the blockchain.
  • the unified interface for accessing the underlying blockchain of the blockchain includes the creation of data , Query, modify and delete (create read update delete, CURD).
  • Index data is stored in a relational database MySQL, corresponding to the data type on a blockchain distributed database, and a one-to-one index data table is created in the index database.
  • the structure of the index data table contains all the information of the data structure in the blockchain distributed database. For example: Store user points data on the blockchain. The user points data includes user ID, user name, and user points. Then create Table 1 user points user index table in the index database.
  • Table 1 User score user index table
  • Field Name Field Type Remarks user_id bigint User ID, primary key user_name varchar username point int account credits data_id varchar Index identification, corresponding to the key of the blockchain data
  • Table 1 includes an index identification field data_id, which corresponds to the key key for storing data on the blockchain distributed database.
  • the server must query or store data on the blockchain distributed database according to the index identification.
  • Each index table in the index database contains a data_id field.
  • the data_id is unique in the index database and corresponds to the key in the blockchain distributed database one by one to establish the corresponding relationship between the index data and the blockchain data .
  • the server obtains the target structured query language SQL statement of the business request, and the target SQL statement is a legal statement that conforms to the SQL syntax rules.
  • the SQL statement is consistent with the SQL statement used to access the relational database, including four SQL statements inserting insert, modifying update, querying select, and deleting delete, corresponding to different interfaces.
  • the server receives the initial SQL statement and parameters, encapsulates the initial SQL statement and parameters, and the server calls the relevant interface to obtain the encapsulated initial SQL statement and parameters to obtain the target SQL statement.
  • the target SQL statement is a legal statement. The legality of the SQL has been judged before the business request, and the statement that does not conform to the SQL grammar rules is eliminated.
  • SQL structured query language
  • SQL is a database query and programming language, including SQL syntax rules, used to access data and manage relational database systems, SQL statements can be used to execute various Various operations, such as inserting data into the database, modifying data in the database, and extracting data from the database.
  • the server processes the target SQL statement according to the preset algorithm to obtain the abstract syntax tree. Specifically, the server parses the target SQL statement according to the SQL parser, and the parsing includes lexical analysis and syntax analysis. Among them, lexical analysis refers to splitting the target SQL statement into lexical units that cannot be subdivided. In SQL grammar, lexical units include keywords, identifiers, literals, operators, and delimiters. For example, when the server reads the UPDATE of the target SQL statement, the server determines that the first character "U" meets the rules of keywords and identifiers, and the second character "P" also meets the rules of keywords and identifiers.
  • the server judges that the rule is not met, and the server has completed the recognition of a lexical unit.
  • UPDATE is not only a keyword defined by the SQL specification, but also satisfies the rules of identifiers. Therefore, when a lexical unit is an identifier, the SQL parser judges the priority to determine whether a lexical unit is a keyword, and the priority of the keyword is high In the identifier rules.
  • Other rules include that characters starting with a number are read according to the literal value of the numerical rules; those starting with double quotation marks or single quotation marks are read according to the literal value of the string rules; operators or delimiters are read according to the symbol characteristics Recognition.
  • the grammatical analysis obtains a lexical unit from the lexical analysis each time. If the rules are met, the extraction and matching of the next lexical unit will continue until the end of the string; if the rules are not met, an error will be prompted and the analysis will end.
  • the grammar analysis finally converts the target SQL statement into an abstract syntax tree.
  • the server uses the SQL Parser module of the database connection pool druid to parse the target SQL statement, and parse the natural semantic SQL statement into a more abstract data structure, that is, an abstract syntax tree (AST).
  • AST is a tree representation of the abstract syntax structure of the source code. Each node on the tree represents a structure in the source code. The AST does not represent every detail of the actual syntax. For example, Nested parentheses are implicit in the structure of the tree and are not presented as nodes.
  • the logical execution plan includes inserting the data plan, modifying the data plan, and querying the data plan;
  • the server logically executes the plan according to the abstract syntax tree.
  • the logical execution plan includes inserting the data plan, modifying the data plan, and querying the data plan.
  • the server obtains SQL elements and data according to the abstract syntax tree, and generates a logical execution plan.
  • the logical execution plan describes what data needs to be queried or stored, and the logical execution plan includes insert data plan, modify data plan, and query data plan.
  • a query request for user points the server parses the received SQL query select statement, decomposes the original SQL string into a logical execution plan, that is, reads the value of the point field from the user index table, and the filter condition is the user name user_name The value is Tom's record.
  • the blockchain distributed database is used to store and query data
  • the server reads and writes the blockchain distributed database according to the logic generation plan and the index database to obtain the read and write results.
  • the blockchain distributed database is used to store and query data.
  • the read and write operations are inserted according to SQL commands into insert, modified update and query select.
  • the server parses the SQL statement to generate a logical execution plan, it operates the blockchain distributed database in conjunction with the index database to complete data query and storage operations.
  • the server When detecting that the logical execution plan is an insert data plan, the server performs an insert operation on the index database and the blockchain distributed database to obtain the read and write results. Specifically, the server generates the first index identifier; the server performs an insert operation on the index database according to the inserted data plan and the first index identifier to obtain the primary key value returned by the index database; the server queries the index database according to the primary key value, and obtains the returned value from the index database Insert data; the server performs an insert operation on the blockchain distributed database according to the first index identifier and the inserted data.
  • the server For example, for a request to insert user points data, the server first sets the first index identifier data_id of the user points index table to the character string USER_1, and then the server writes the data to the user of the index database according to the user points insertion data plan and the first index identifier In the score index table, get the primary key value 1 of the primary key user_id, query the user score index table according to the primary key value 1, and get the query data.
  • JSON JavaScript Object Notation
  • the server When detecting that the logical execution plan is a modified data plan, the server modifies the index database and the blockchain distributed database to obtain the read and write results. According to the second index identification, the data is queried from the blockchain distributed database to obtain the initial data, and the initial data is updated and then written into the blockchain distributed database to ensure the data integrity and consistency of the blockchain distributed database.
  • the server obtains the corresponding logical execution plan according to the request, and obtains the update element, then the server first updates the index database and obtains the second index identification data_id of the updated data Value, use the second index identifier as the key key, query the blockchain distributed database to obtain the initial value, which is JSON format data, modify the user’s point value for the initial value to obtain the target value, which is also JSON format data, and finally the server calls the underlying interface of the blockchain to write the key and target value into the blockchain distributed database.
  • the server When it is detected that the logical execution plan is a query data plan, the server performs a query operation on the index database and the blockchain distributed database to obtain the read and write results.
  • the server obtains the query results from the blockchain distributed database to ensure the accuracy of the data. For example, for a request to query user points, the server queries the user points data index table according to the query statement, and obtains the value USER_1 of the third index identifier data_id field.
  • the server uses USER_1 as the key to query the blockchain distributed database to obtain the query result.
  • the use of SQL statements is compatible with the query and storage of the blockchain distributed database and the relational database, and the corresponding relationship between the index database and the blockchain distributed database is established to improve the area.
  • Retrieval efficiency of blockchain business information encapsulate the underlying interface of the blockchain, use SQL statements and index databases to achieve data storage and query on the chain, reduce development thresholds, and improve development efficiency.
  • FIG. 2 another embodiment of the blockchain data storage and query method in the embodiment of the present application includes:
  • the server generates an index database according to business requirements.
  • the index database is located in the data middleware of the blockchain.
  • the data middleware also provides a unified interface for accessing the underlying blockchain of the blockchain.
  • the unified interface for accessing the underlying blockchain of the blockchain includes the creation of data , Query, modify and delete (create read update delete CURD).
  • Index data is stored in a relational database MySQL, corresponding to the data type on a blockchain distributed database, and a one-to-one index data table is created in the index database.
  • the structure of the index data table contains all the information of the data structure in the blockchain distributed database. For example: Store user points data on the blockchain. The user points data includes user ID, user name, and user points. Then create Table 1 user points user index table in the index database.
  • Table 1 includes an index identification field data_id, which corresponds to the key key for storing data on the blockchain distributed database.
  • the server must query or store data on the blockchain distributed database according to the index identification.
  • Each index table in the index database contains an index identification field.
  • the index identification is unique in the index database and corresponds to the key key in the blockchain distributed database one by one.
  • the index data and the blockchain data are correspondingly established. relationship. For example, if the index identifier data_id stored in the user score index table is USER_1, then a piece of user score data with a key of USER_1 is also stored in the blockchain distributed database.
  • the index identifier is named data_id or index_id, which does not conflict with other fields of the index table in the index database, and the specifics are not limited here.
  • target SQL statement is a legal statement that complies with SQL grammar rules
  • the server obtains the target structured query language SQL statement requested by the database, and the target SQL statement is a legal statement that conforms to the SQL syntax rules.
  • the SQL statement is consistent with the SQL statement used to access the relational database, including four SQL statements inserting insert, modifying update, querying select, and deleting delete, corresponding to different interfaces.
  • the target SQL statement is a legal statement. The legality of the SQL has been judged before the business request, and the statement that does not conform to the SQL grammar rules is eliminated.
  • the server receives a request including a target structured query language SQL statement and parameters.
  • the request is a data format that encapsulates the target SQL statement and parameters according to preset rules, so that the server can obtain the target SQL statement and parameters in a uniform manner. For example, after encapsulating the select statement and parameter param of the database SQL query of user points, as shown in Table 2 User Points Query Request Table.
  • the parameter sql is a structured query language SQL statement
  • the parameter param is a collection of other parameters of the JSON data structure.
  • the server calls the relevant interface to parse the request including the target SQL statement and parameters, obtains the parameter sql, and obtains the target SQL statement.
  • SQL structured query language
  • SQL is a database query and programming language, including SQL syntax rules, used to access data and manage relational database systems, SQL statements can be used to execute various Various operations, such as inserting data into the database, modifying data in the database, and extracting data from the database.
  • the server sets a configuration file for connecting to the database.
  • the configuration file includes two configuration files, one is the configuration file for connecting to the relational database, and the other is the configuration file for connecting to the blockchain.
  • the parameter names of the two configuration files are the same. Both include the URL of the accessed connection address and the database driver, but the parameter values are different.
  • the server processes the target SQL statement according to the preset algorithm to obtain the abstract syntax tree. Specifically, the server parses the target SQL statement according to the SQL parser, and the parsing includes lexical analysis and syntax analysis. Among them, lexical analysis refers to splitting the target SQL statement into lexical units that cannot be subdivided. In SQL grammar, lexical units include keywords, identifiers, literals, operators, and delimiters. For example, when the server reads the UPDATE of the target SQL statement, the server determines that the first character "U" meets the rules of keywords and identifiers, and the second character "P" also meets the rules of keywords and identifiers.
  • the server determines that the rule is not met, and then determines the recognition of a lexical unit.
  • UPDATE is not only a keyword defined by the SQL specification, but also satisfies the identifier rules. Therefore, when a lexical unit is an identifier, the SQL parser judges the priority to determine whether the lexical unit is a keyword.
  • Other rules include that characters starting with a number are read according to the literal value of the numerical rules; those starting with double quotation marks or single quotation marks are read according to the literal value of the string rules; operators or delimiters are read according to the symbol characteristics Recognition.
  • the grammatical analysis obtains a lexical unit from the lexical analysis each time. If the rules are met, the extraction and matching of the next lexical unit will continue until the end of the string; if the rules are not met, an error will be prompted and the analysis will end.
  • the grammar analysis finally converts the target SQL statement into an abstract syntax tree. For example, for the target SQL statement:
  • the lexical unit obtained includes the keywords SELECT, FROM and WHERE; the identifiers are user_id, user_name, point and user; the literal is 10; the operator is >; the delimiter is, and; .
  • Grammatical analysis is based on the lexical unit for regular loop processing and branch selection, and finally parsed into an abstract syntax tree including the root node.
  • the server uses the SQL Parser module of the database connection pool druid to parse the target SQL statement, and parse the natural semantic SQL statement into a more abstract data structure, that is, an abstract syntax tree (AST).
  • AST is a tree representation of the abstract syntax structure of the source code. Each node on the tree represents a structure in the source code. The AST does not represent every detail of the actual syntax. For example, Nested parentheses are implicit in the structure of the tree and are not presented as nodes.
  • the server generates a logical execution plan according to the abstract syntax tree, and the logical execution plan includes inserting the data plan, modifying the data plan, and querying the data plan.
  • the server obtains SQL elements and data according to the abstract syntax tree, and generates a logical execution plan.
  • the logical execution plan includes insert data plan, modify data plan, and query data plan, that is, it describes what data needs to be queried or what data is stored.
  • inserting data plan includes inserting insert element
  • modifying data plan includes modifying update element and query
  • the data plan includes the query select element.
  • the server uses the visitor mode to traverse the AST syntax tree to obtain each element in the target SQL statement, which includes basic SQL elements and related data.
  • the visitor pattern also known as the visitor pattern, separates structure and data, writes a visitor to visit the elements in the data structure, and then delegates all the processing of each element to the visitor class.
  • the server generates a logical execution plan through the elements in the SQL statement.
  • the logical plan describes which data needs to be queried or stored.
  • the data middleware gives the physical realization of the logical execution plan, calls the underlying block link port, and completes the actual execution.
  • Table 2 user points query request form the server parses the received SQL query select statement, and decomposes the original SQL string into a logical execution plan, that is, reads the point field value from the user points user index table, the filter condition is user
  • the name user_name is a record with Tom.
  • Logical execution plans include inserting data plans, modifying data plans, and querying data plans.
  • the server determines whether the logical execution plan is an insert data plan, a modified data plan, or a query data plan. Specifically, the server determines whether the logical execution plan includes the insert element of SQL. If the logical execution plan includes the insert element of SQL, it determines that the logical execution plan is an insert data plan; the server determines whether the logical execution plan includes the update element of SQL. If the plan includes the update element of SQL, the logical execution plan is determined to be a modified data plan; the server determines whether the logical execution plan includes the select element of SQL, and if the logical execution plan includes the select element of SQL, the logical execution plan is determined to be an insert data plan.
  • the server operates the blockchain distributed database according to the logical generation plan and the index database, and the blockchain distributed database is used to store and query data. The operation is divided into insert according to the SQL command, update and query select. After the server parses the SQL statement to generate a logical execution plan, it operates the blockchain distributed database in conjunction with the index database to complete data query and storage operations.
  • logical execution plan is an insert data plan, insert the index database and the blockchain distributed database to obtain the read and write results;
  • the server performs an insert operation on the index database and the blockchain distributed database to obtain the read and write results. Specifically, the server generates a first index identifier, where the first index identifier is dynamically generated by the server according to preset rules and is unique; the server generates a SQL insert statement according to the insert data plan and the first index identifier, and further, the server obtains the insert The insert element, index table name, multiple field names to be inserted into the data and their corresponding field values in the data plan; the server obtains the index field name corresponding to the first index identifier; the server converts the field names and first index identifiers of multiple data to be inserted The corresponding index field name is set to multiple insertion index data table fields, and the field values and first index identifiers corresponding to the multiple data to be inserted are set to multiple insertion index data in the order corresponding to the multiple insertion index data table fields.
  • the server constructs the SQL insert statement into the index database according to the SQL syntax rules for the insert element, the index table name, the data values corresponding to the insert element, the index table name, and the multiple insert index data table fields;
  • the server inserts the index database according to the SQL insert statement, and obtains the primary key value returned by the index database;
  • the server queries the index database according to the primary key value to obtain the inserted data returned by the index database;
  • the server compares the block according to the first index identifier and the inserted data
  • the chain distributed database performs an insert operation to obtain an insert result, which includes successful data insertion and data insertion failure, and the insert result is set as the read-write result. For example, an application requests to write user points.
  • the server generates the first index identifier USER_1 according to the preset rules, and its SQL insert statement is as follows:
  • the server then writes data into the user score user index table in the index database according to the SQL insert statement, and obtains the insertion result, as shown in Table 3, insert user score index table.
  • the server queries the user table in the index database to obtain the query data, uses USER_1 in the query data as the key key of the blockchain distributed database, and encapsulates other fields and data into JavaScript Object Notation (JSON) format , And set the JSON data ⁇ 'userId':1,'userName':'Tom',point:0 ⁇ as the value of the blockchain distributed database, and then call the underlying interface of the blockchain to write the key and value
  • JSON JavaScript Object Notation
  • Table 4 Blockchain distributed data table
  • logical execution plan is to modify the data plan, modify the index database and the blockchain distributed database to obtain the read and write results;
  • the server modifies the index database and the blockchain distributed database to obtain the read and write results.
  • the SQL modification statement is generated according to the modified data plan.
  • the server obtains the update element, index table name, modification condition, field names of multiple data to be modified and respective corresponding field values in the modified data plan; the server according to the SQL syntax rules Rebuild the update element, index table name, modification condition, field names of multiple data to be modified, and respective corresponding field values to obtain the SQL modification statement for modifying the index database; update the index database according to the SQL modification statement to obtain the second index identification; Query the blockchain distributed database according to the second index identifier to obtain the initial data of the blockchain; modify the initial data of the blockchain to obtain the target data of the blockchain; write the target data of the blockchain into the area according to the second index identifier
  • the block chain distributed database obtains the modification result, the modification result includes the successful modification of the data and the modification failure, and the modification result is set as the read-write result.
  • the server executes the SQL modification statement to update the user table in the index database, and the updated user table data is shown in Table 5 to update the user score index table.
  • the updated blockchain data is shown in Table 6 to update the blockchain distributed database, and Return the modified result to the terminal.
  • the data is queried from the blockchain distributed database according to the second index identification to obtain the initial data, and the initial data is updated and then written to the blockchain distributed database to ensure that the data in the blockchain distributed database is complete Sex and consistency.
  • the logical execution plan is a query data plan, perform a query operation on the index database and the blockchain distributed database to obtain read and write results.
  • the logical execution plan is a query data plan
  • the SQL query statement is generated according to the query data plan.
  • the server obtains the select element, index table name, query condition, and multiple field names to be queried in the query data plan; the server performs the query on the select element and index according to the SQL syntax rules
  • the table name, query conditions and multiple field names to be queried are reconstructed to obtain the SQL query statement for querying the index database; query the index database according to the SQL query statement to obtain the third index identification; read the blockchain according to the third index identification Distributed database, get the query result, and set the query result as the read-write result.
  • the basic idea of processing is to first parse the target SQL statement, analyze the logical execution plan, and then rewrite the SQL statement on the logical execution plan to obtain the third
  • the index identifies data_id, and reads the basic data from the blockchain distributed database according to the data_id, and finally aggregates and calculates the data to obtain the final query result.
  • the server sends the first message to the message queue to obtain the transaction identifier; the server writes the index database according to the transaction identifier to obtain the write result; the server determines whether the write result is successful; if the write result is If the write is successful, the server writes the blockchain distributed database through the message queue; if the write result is a write failure, the server deletes the index database through the message queue.
  • the server first writes the data into the index database, and then writes the data into the blockchain distributed database according to the index identification.
  • the server uses the transaction message function provided by the distributed message middleware RocketMQ to write index data and send distribution
  • the message is sent to RocketMQ in one transaction, ensuring that the writing of data and sending of the message succeed or fail at the same time.
  • the server writing to the blockchain distributed database is completed by detecting RocketMQ messages, adding the write log table to ensure idempotence, and achieving the ultimate consistency of the index database and the blockchain distributed database.
  • the use of SQL statements is compatible with the query and storage of the blockchain distributed database and the relational database, and the corresponding relationship between the index database and the blockchain distributed database is established to improve the area.
  • Retrieval efficiency of blockchain business information encapsulate the underlying interface of the blockchain, use SQL statements and index databases to achieve data storage and query on the chain, reduce development thresholds, and improve development efficiency.
  • An embodiment of the query device includes: a first generating unit 301, used to generate an index database; an obtaining unit 302, used to obtain a target structured query language SQL statement, the target SQL statement is a legal statement that conforms to SQL grammar rules; a parsing unit 303 , Used to parse the target SQL statement according to a preset algorithm to obtain an abstract syntax tree; the second generating unit 304 is used to generate a logical execution plan according to the abstract syntax tree, the logical execution plan includes inserting a data plan, modifying a data plan, and querying data Plan; The read-write unit 305 is used to perform read and write operations on the blockchain distributed database according to the logic generation plan and index database to obtain the read and write results.
  • the blockchain distributed database is used to store and query data.
  • the use of SQL statements is compatible with the query and storage of the blockchain distributed database and the relational database, and the corresponding relationship between the index database and the blockchain distributed database is established to improve the area.
  • Retrieval efficiency of blockchain business information encapsulate the underlying interface of the blockchain, use SQL statements and index databases to achieve data storage and query on the chain, reduce development thresholds, and improve development efficiency.
  • another embodiment of the device for storing and querying blockchain data in the embodiment of the present invention includes: a first generating unit 301, configured to generate an index database; and an acquiring unit 302, configured to acquire a target structured query language SQL Statement, the target SQL statement is a legal statement that conforms to the SQL grammar rules; the parsing unit 303 is used to parse the target SQL statement according to a preset algorithm to obtain an abstract syntax tree; the second generating unit 304 is used to generate logic according to the abstract syntax tree Execution plan, the logical execution plan includes inserting data plan, modifying data plan and querying data plan; the reading and writing unit 305 is used to read and write the blockchain distributed database according to the logic generation plan and index database to obtain the read and write results, The blockchain distributed database is used to store and query data.
  • the second generating unit 304 may also be specifically used to: traverse the abstract syntax tree through the visitor mode to obtain the elements of the target SQL statement; generate a logical execution plan according to the elements of the target SQL statement, and the logical execution plan includes an insert data plan , Modify the data plan and query the data plan.
  • the reading and writing unit 305 may further include: a judging subunit 3051, for judging whether the logical execution plan is an insert data plan, a modified data plan, or a query data plan; an insert subunit 3052, if the logical execution plan is an insert data plan , It is used to insert operations on the index database and the blockchain distributed database to obtain the read and write results; the modification subunit 3053, if the logical execution plan is to modify the data plan, it is used for the index database and the blockchain distributed database Perform modification operations to obtain read and write results; the query subunit 3054, if the logical execution plan is a query data plan, is used for query operations on the index database and blockchain distributed database to obtain the read and write results.
  • a judging subunit 3051 for judging whether the logical execution plan is an insert data plan, a modified data plan, or a query data plan
  • an insert subunit 3052 if the logical execution plan is an insert data plan , It is used to insert operations on the index database and the blockchain distributed database to obtain the
  • the insert subunit 3052 can also be specifically used to: generate a first index identifier; generate a SQL insert statement according to the insert data plan and the first index identifier; perform an insert operation on the index database according to the SQL insert statement, and obtain the return value of the index database Primary key value; query the index database according to the primary key value to get the inserted data returned by the index database; insert the blockchain distributed database according to the first index identifier and the inserted data to obtain the insert result, and set the insert result to read and write result.
  • the modification subunit 3053 can also be specifically used to: generate SQL modification statements according to the modified data plan; update the index database according to the SQL modification statements to obtain the second index identification; query the blockchain distributed database according to the second index identification, Obtain the initial data of the blockchain; modify the initial data of the blockchain to obtain the target data of the blockchain; write the target data of the blockchain into the distributed database of the blockchain according to the second index identification, obtain the modified result, and then modify the result Set to read and write results.
  • the query subunit 3054 can also be specifically used to: generate SQL query statements according to the query data plan; query the index database according to the SQL query statements to obtain the third index identifier; read the blockchain distributed database according to the third index identifier To get the query result, and set the query result as the read-write result.
  • the blockchain data storage and query device further includes: a sending unit 306, configured to send a first message to the message queue to obtain a transaction identifier; and a first writing unit 307, configured to write to the index database according to the transaction identifier
  • the writing result is obtained;
  • the judgment unit 308 is used to judge whether the writing result is successful;
  • the second writing unit 309 if the writing result is successful, is used to check the blockchain through the message queue
  • the distributed database performs a write operation;
  • the deleting unit 310 if the write result is a write failure, is used to delete the index database through the message queue.
  • the use of SQL statements is compatible with query and storage in the blockchain distributed database and the relational database, and the corresponding relationship between the index database and the blockchain distributed database is established to improve the area.
  • Retrieval efficiency of blockchain business information encapsulate the underlying interface of the blockchain, use SQL statements and index databases to achieve data storage and query on the chain, reduce development thresholds, and improve development efficiency.
  • the above figures 3 and 4 describe in detail the block chain data storage and query device in the embodiment of the present invention from the perspective of modular functional entities. The following describes the block chain data storage and query device in the embodiment of the present invention from the perspective of hardware processing Give a detailed description.
  • FIG. 4 is a schematic structural diagram of a blockchain data storage and query device provided by an embodiment of the present application.
  • the blockchain data storage and query device 500 may have relatively large differences due to different configurations or performance, and may include one or One or more processors (central processing units, CPU) 501 (for example, one or more processors) and memory 509, one or more storage media 508 for storing application programs 509 or data 509 (for example, one or one storage device with a large amount of ).
  • the memory 509 and the storage medium 508 may be short-term storage or persistent storage.
  • the program stored in the storage medium 508 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations for storing and querying blockchain data.
  • the processor 501 may be configured to communicate with the storage medium 508, and execute a series of instruction operations in the storage medium 508 on the blockchain data storage and query device 500.
  • the instructions include: 101. Generate an index database; 102. Obtain a target structured query language SQL statement, where the target SQL statement is a legal statement that complies with the SQL grammar rules; 103. parse the target SQL statement according to a preset algorithm , Obtain an abstract syntax tree; 104, generate a logical execution plan according to the abstract syntax tree, the logical execution plan includes inserting a data plan, modifying a data plan, and querying a data plan; 105, generating a plan and the index database according to the logic Perform read and write operations on the blockchain distributed database to obtain read and write results.
  • the blockchain distributed database is used to store and query data.
  • the blockchain data storage and query device 500 may also include one or more power supplies 502, one or more wired or wireless network interfaces 503, one or more input and output interfaces 504, and/or, one or more operating systems 505 , Such as Windows Serve, Mac OS X, Unix, Linux, FreeBSD and so on.
  • operating systems 505 Such as Windows Serve, Mac OS X, Unix, Linux, FreeBSD and so on.
  • FIG. 4 does not constitute a limitation on the blockchain data storage and query device, and may include more or fewer components than shown in the figure, or Combining certain components, or different component arrangements.
  • the functional units in the various embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit.
  • the above-mentioned integrated unit can be implemented in the form of hardware or software functional unit. If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it may be stored in a computer-readable storage medium, which may be a non-volatile readable storage The medium may also be a volatile readable storage medium.
  • the technical solution of this application essentially or the part that contributes to the existing technology or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium , Including several instructions to make a computer device (which can be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the method described in each embodiment of the present application.
  • the steps include: 101. Generating an index database; 102. Obtaining a target structured query language SQL statement, where the target SQL statement is a legal statement complying with SQL grammar rules; 103.
  • Analyzing the target SQL statement according to a preset algorithm Obtain an abstract syntax tree; 104, generate a logical execution plan according to the abstract syntax tree, the logical execution plan includes inserting a data plan, modifying a data plan, and querying a data plan; 105, generating a plan and the index database according to the logic Perform read and write operations on the blockchain distributed database to obtain read and write results.
  • the blockchain distributed database is used to store and query data.
  • the aforementioned storage media include: U disk, mobile hard disk, read-only memory (read-only memory, ROM), random access memory (random access memory, RAM), magnetic disk or optical disk and other media that can store program code .

Abstract

La présente invention concerne le domaine des chaînes de blocs, et plus particulièrement, le domaine de l'amélioration de la structure des blocs. L'invention concerne un procédé, un appareil et un dispositif d'interrogation et de stockage de données de chaînes de blocs, et un support d'enregistrement. Le procédé d'interrogation et de stockage de données de chaînes de blocs consiste à : générer une base de données d'index ; obtenir une instruction de langage d'interrogation structuré (SQL) cible, l'instruction SQL cible étant une instruction légitime conforme à une règle de syntaxe SQL ; analyser l'instruction SQL cible selon un algorithme prédéfini pour obtenir un arbre de syntaxe abstraite ; générer un plan d'exécution logique selon l'arbre de syntaxe abstraite, le plan d'exécution logique comprenant un plan d'insertion de données, un plan de modification de données et un plan d'interrogation de données ; et effectuer une opération de lecture-écriture sur une base de données réparties de chaînes de blocs selon un plan de génération logique et la base de données d'index pour obtenir un résultat de lecture-écriture, la base de données réparties de chaînes de blocs étant utilisée pour interroger et stocker des données. Dans la présente invention, en encapsulant une interface sous-jacente de chaînes de blocs et en utilisant une instruction SQL et une base de données d'index pour réaliser une interrogation et un stockage de chaînage de données, le seuil de développement est abaissé, et l'efficacité de récupération et de développement est améliorée.
PCT/CN2020/087585 2019-05-22 2020-04-28 Procédé, appareil et dispositif d'interrogation et de stockage de données de chaînes de blocs, et support d'enregistrement WO2020233367A1 (fr)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910427137.8A CN110309196A (zh) 2019-05-22 2019-05-22 区块链数据存储和查询方法、装置、设备及存储介质
CN201910427137.8 2019-05-22

Publications (1)

Publication Number Publication Date
WO2020233367A1 true WO2020233367A1 (fr) 2020-11-26

Family

ID=68074933

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/087585 WO2020233367A1 (fr) 2019-05-22 2020-04-28 Procédé, appareil et dispositif d'interrogation et de stockage de données de chaînes de blocs, et support d'enregistrement

Country Status (2)

Country Link
CN (1) CN110309196A (fr)
WO (1) WO2020233367A1 (fr)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112527794A (zh) * 2020-12-07 2021-03-19 广州海量数据库技术有限公司 实现数据库中集合数据类型的数据处理方法及系统
CN113312373A (zh) * 2021-05-12 2021-08-27 上海哲锦信息科技有限公司 一种数据结构化查询语句的解析方法及设备
CN113672781A (zh) * 2021-08-20 2021-11-19 平安国际智慧城市科技股份有限公司 数据查询方法、装置、电子设备及存储介质
CN113688148A (zh) * 2021-07-13 2021-11-23 交控科技股份有限公司 城轨数据查询方法、装置、电子设备及可读存储介质
CN114138899A (zh) * 2021-11-22 2022-03-04 支付宝(杭州)信息技术有限公司 基于区块链的数据流转方法及装置
CN117055895A (zh) * 2023-08-07 2023-11-14 北京东方金信科技股份有限公司 一种将sql语句转换为http接口的方法、系统和可读介质

Families Citing this family (31)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110309196A (zh) * 2019-05-22 2019-10-08 深圳壹账通智能科技有限公司 区块链数据存储和查询方法、装置、设备及存储介质
CN111046066B (zh) * 2019-12-09 2023-05-12 上海达梦数据库有限公司 远程数据库对象的优化方法、装置、设备及存储介质
CN111177182B (zh) * 2019-12-19 2023-06-30 达闼机器人股份有限公司 数据查询方法和装置、存储介质和电子设备
CN111309765B (zh) * 2020-01-22 2023-07-04 北京飞漫软件技术有限公司 一种直接查询结构化数据的方法及装置
CN111414438B (zh) * 2020-03-13 2023-06-02 上海银赛计算机科技有限公司 基于mysql的实时规则匹配方法及系统
CN111400297B (zh) * 2020-03-19 2023-11-03 上海德拓信息技术股份有限公司 基于Hadoop的海量数据数据质量校验方法
CN111310137B (zh) * 2020-03-23 2022-08-26 杭州溪塔科技有限公司 一种区块链关联数据存证方法、装置及电子设备
CN111680067A (zh) * 2020-05-28 2020-09-18 中国工商银行股份有限公司 基于区块链的数据处理方法、装置及系统
CN111475588B (zh) * 2020-06-19 2020-12-08 阿里云计算有限公司 数据处理方法及装置
CN111767301B (zh) * 2020-06-24 2022-07-15 江苏荣泽信息科技股份有限公司 一种基于区块链的关系型数据库解决方法
CN112052255B (zh) * 2020-09-02 2022-05-03 福建天晴在线互动科技有限公司 一种自上而下拆分多表慢查询的sql解释方法及其装置
CN112069201A (zh) * 2020-09-04 2020-12-11 北京百度网讯科技有限公司 目标数据的获取方法和装置
CN113297306B (zh) * 2020-09-30 2023-02-07 阿里云计算有限公司 数据处理方法及装置
CN112487027B (zh) * 2020-12-02 2022-08-23 山东浪潮科学研究院有限公司 基于区块链电子交易的高效数据查询实现方法
CN112506946B (zh) * 2020-12-03 2024-04-05 平安科技(深圳)有限公司 业务数据查询方法、装置、设备及存储介质
CN112579610A (zh) * 2020-12-23 2021-03-30 安徽航天信息有限公司 多数据源结构分析方法、系统、终端设备及存储介质
CN112667489B (zh) * 2020-12-28 2022-09-16 杭州趣链科技有限公司 区块链中数据查询工作量的计量方法、装置及终端
WO2022140936A1 (fr) * 2020-12-28 2022-07-07 杭州趣链科技有限公司 Procédé et dispositif de mesure de charge de travail d'interrogation de données dans une chaîne de blocs, et terminal
CN112711592B (zh) * 2020-12-31 2022-06-28 中国科学院计算技术研究所数字经济产业研究院 基于区块链的数据索引方法
CN112817990B (zh) * 2021-01-28 2024-03-08 北京百度网讯科技有限公司 数据处理方法、装置、电子设备以及可读存储介质
CN113204571B (zh) * 2021-04-23 2022-08-30 新华三大数据技术有限公司 涉及写入操作的sql执行方法、装置及存储介质
CN113139019B (zh) * 2021-06-18 2022-03-25 智己汽车科技有限公司 在区块链上记录车辆的里程数据的方法和装置
CN113535777B (zh) * 2021-06-24 2023-05-23 上海浦东发展银行股份有限公司 数据库查询方法、装置和系统
CN113434503A (zh) * 2021-06-25 2021-09-24 上海佩俪信息科技有限公司 一种区块链浏览方法及系统
CN113626423B (zh) * 2021-06-29 2024-01-30 欧电云信息科技(江苏)有限公司 业务数据库的日志管理方法、装置、系统
CN113687827B (zh) * 2021-08-24 2024-03-12 平安国际智慧城市科技股份有限公司 基于微件的数据列表生成方法、装置、设备及存储介质
CN114238469B (zh) * 2021-12-07 2022-07-12 杭州天均数聚科技有限公司 数据提取接口开放方法、装置、计算机设备及存储介质
CN114880351B (zh) * 2022-05-31 2024-02-06 中国电信股份有限公司 慢查询语句的识别方法及装置、存储介质、电子设备
CN115421698A (zh) * 2022-08-30 2022-12-02 敏于行(北京)科技有限公司 基于声明式和分布式账本的数据处理方法、装置及电子装置
CN116089476B (zh) * 2023-04-07 2023-07-04 北京宝兰德软件股份有限公司 数据查询方法、装置及电子设备
CN116975126B (zh) * 2023-09-25 2023-12-19 恒生电子股份有限公司 数据查询方法、装置、计算设备和计算机可读存储介质

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6325780B1 (en) * 1999-09-13 2001-12-04 Advanced Cardiovascular Systems, Inc. Inflatable member formed of liquid crystal polymeric material blend
CN109241104A (zh) * 2018-10-12 2019-01-18 北京聚云位智信息科技有限公司 决策型分布式数据库系统中aisql的解析器及其实现方法
CN109492053A (zh) * 2018-11-08 2019-03-19 北京百度网讯科技有限公司 用于访问数据的方法和装置
CN109559231A (zh) * 2018-12-29 2019-04-02 华东师范大学 一种面向区块链的追溯查询方法
CN110309196A (zh) * 2019-05-22 2019-10-08 深圳壹账通智能科技有限公司 区块链数据存储和查询方法、装置、设备及存储介质

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105302842A (zh) * 2014-07-31 2016-02-03 北大方正集团有限公司 一种数据处理方法及装置
CN105608086B (zh) * 2014-11-17 2021-07-27 中兴通讯股份有限公司 分布式数据库系统的事务处理方法及装置
WO2017136527A1 (fr) * 2016-02-05 2017-08-10 Manifold Technology, Inc. Base de données améliorée par une chaîne de blocs
CN108563694B (zh) * 2018-03-19 2021-04-13 广州视源电子科技股份有限公司 对逻辑删除的sql执行方法、装置、计算机设备和存储介质
CN108647361B (zh) * 2018-05-21 2021-12-03 中国工商银行股份有限公司 一种基于区块链的数据存储方法、装置及系统
CN109522008B (zh) * 2018-11-06 2020-07-10 陕西医链区块链集团有限公司 一种区块链智能合约构建方法
CN109741192A (zh) * 2018-11-15 2019-05-10 深圳壹账通智能科技有限公司 基于区块链的数据存储方法、装置、设备及可读存储介质
CN109784918A (zh) * 2018-12-15 2019-05-21 深圳壹账通智能科技有限公司 基于区块链的信息监督方法、装置、设备和存储介质

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6325780B1 (en) * 1999-09-13 2001-12-04 Advanced Cardiovascular Systems, Inc. Inflatable member formed of liquid crystal polymeric material blend
CN109241104A (zh) * 2018-10-12 2019-01-18 北京聚云位智信息科技有限公司 决策型分布式数据库系统中aisql的解析器及其实现方法
CN109492053A (zh) * 2018-11-08 2019-03-19 北京百度网讯科技有限公司 用于访问数据的方法和装置
CN109559231A (zh) * 2018-12-29 2019-04-02 华东师范大学 一种面向区块链的追溯查询方法
CN110309196A (zh) * 2019-05-22 2019-10-08 深圳壹账通智能科技有限公司 区块链数据存储和查询方法、装置、设备及存储介质

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112527794A (zh) * 2020-12-07 2021-03-19 广州海量数据库技术有限公司 实现数据库中集合数据类型的数据处理方法及系统
CN113312373A (zh) * 2021-05-12 2021-08-27 上海哲锦信息科技有限公司 一种数据结构化查询语句的解析方法及设备
CN113688148A (zh) * 2021-07-13 2021-11-23 交控科技股份有限公司 城轨数据查询方法、装置、电子设备及可读存储介质
CN113672781A (zh) * 2021-08-20 2021-11-19 平安国际智慧城市科技股份有限公司 数据查询方法、装置、电子设备及存储介质
CN114138899A (zh) * 2021-11-22 2022-03-04 支付宝(杭州)信息技术有限公司 基于区块链的数据流转方法及装置
CN117055895A (zh) * 2023-08-07 2023-11-14 北京东方金信科技股份有限公司 一种将sql语句转换为http接口的方法、系统和可读介质
CN117055895B (zh) * 2023-08-07 2024-03-29 北京东方金信科技股份有限公司 一种将sql语句转换为http接口的方法、系统和可读介质

Also Published As

Publication number Publication date
CN110309196A (zh) 2019-10-08

Similar Documents

Publication Publication Date Title
WO2020233367A1 (fr) Procédé, appareil et dispositif d'interrogation et de stockage de données de chaînes de blocs, et support d'enregistrement
US11681702B2 (en) Conversion of model views into relational models
US8065323B2 (en) Offline validation of data in a database system for foreign key constraints
US11475034B2 (en) Schemaless to relational representation conversion
US8782081B2 (en) Query template definition and transformation
US7822710B1 (en) System and method for data collection
CN103168300B (zh) 具有外连接的立即实体化视图的增量维护
WO2018177060A1 (fr) Procédé d'optimisation de requête et dispositif associé
CN109614413B (zh) 一种内存流式计算平台系统
WO2021139426A1 (fr) Procédé, dispositif et appareil d'interrogation de données dans une base de données, et support de stockage
CN111177788A (zh) Hive的动态脱敏方法及动态脱敏系统
US20090144252A1 (en) System and method for translating and executing update requests
US20160034582A1 (en) Computing device and method for executing database operation command
US20210209098A1 (en) Converting database language statements between dialects
CN110990425B (zh) 硬件数据库的jdbc驱动方法及装置
CN108431766B (zh) 用于访问数据库的方法和系统
WO2022057357A1 (fr) Procédé et appareil d'interrogation de données, et système de base de données
CN112235311B (zh) Ovsdb客户端代码自动生成方法、系统、设备及介质
CN113297250A (zh) 一种分布式数据库多表关联查询的方法及系统
CN107077496A (zh) 用于索引编译以优化索引使用的系统、方法和设备
CN113204571B (zh) 涉及写入操作的sql执行方法、装置及存储介质
WO2019015364A1 (fr) Procédé et dispositif permettant d'exécuter une instruction de langage d'interrogation structuré (sql)
CN105335482B (zh) 面向海量分布式数据库的批量插入方法
JP2022543306A (ja) ブロックチェーンデータ処理の方法、装置、機器及び可読記憶媒体
WO2016177027A1 (fr) Procédé et dispositif d'interrogation de données par lots

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20810779

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20810779

Country of ref document: EP

Kind code of ref document: A1

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205 DATED 18/03/2022)

122 Ep: pct application non-entry in european phase

Ref document number: 20810779

Country of ref document: EP

Kind code of ref document: A1