CN111581181A - Method for automatically generating intelligent contract of block chain based on database data table - Google Patents
Method for automatically generating intelligent contract of block chain based on database data table Download PDFInfo
- Publication number
- CN111581181A CN111581181A CN202010265355.9A CN202010265355A CN111581181A CN 111581181 A CN111581181 A CN 111581181A CN 202010265355 A CN202010265355 A CN 202010265355A CN 111581181 A CN111581181 A CN 111581181A
- Authority
- CN
- China
- Prior art keywords
- data
- intelligent contract
- block chain
- data table
- relational database
- Prior art date
- Legal status (The legal status 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 status listed.)
- Granted
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/21—Design, administration or maintenance of databases
- G06F16/219—Managing data history or versioning
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/22—Indexing; Data structures therefor; Storage structures
- G06F16/2282—Tablespace storage structures; Management thereof
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/23—Updating
- G06F16/2365—Ensuring data consistency and integrity
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/27—Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/60—Software deployment
- G06F8/65—Updates
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/70—Software maintenance or management
- G06F8/71—Version control; Configuration management
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06Q—INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
- G06Q40/00—Finance; Insurance; Tax strategies; Processing of corporate or income taxes
- G06Q40/04—Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Databases & Information Systems (AREA)
- Software Systems (AREA)
- Data Mining & Analysis (AREA)
- Business, Economics & Management (AREA)
- Computer Security & Cryptography (AREA)
- Accounting & Taxation (AREA)
- Finance (AREA)
- Economics (AREA)
- General Business, Economics & Management (AREA)
- Technology Law (AREA)
- Strategic Management (AREA)
- Computing Systems (AREA)
- Marketing (AREA)
- Development Economics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
- Management, Administration, Business Operations System, And Electronic Commerce (AREA)
Abstract
The invention discloses a method for automatically generating a block chain intelligent contract based on a database data table, which comprises the steps of creating the data table in a relational database; and the block chain platform automatically generates the intelligent contract codes by reading the newly-added data table in the relational database. And after the intelligent contract codes are updated, performing automatic compilation and deploying the intelligent contract codes to the block chain platform. The blockchain platform synchronizes data to the relational database. The method of the invention provides a one-to-one mapping relation of data relations between the block chain platform and the relational database, realizes automatic compiling of intelligent contracts, visualizes the data of the block chain platform and realizes automatic synchronization of the data. The method is convenient for developers to write contracts, improves the efficiency and can also improve the management efficiency of data.
Description
Technical Field
The invention relates to the field of a block chain technology, intelligent contracts and relational databases, in particular to a method for automatically generating block chain intelligent contracts based on a database data table.
Background
The block chain technology is a distributed account book and a distributed database in nature, and has the characteristics of decentralization, no tampering, traceability, openness and transparency. An intelligent contract is a piece of program deployed on a blockchain that implements automated processing of traditional contracts in the form of computer instructions. The intelligent contract can respond to the information, can accept and store the information, and can also send the information outwards. Smart contracts always perform operations according to predefined rules. Therefore, the encoding of the smart contract must be performed according to a certain specification.
However, in the actual encoding process of the intelligent contract, due to the difference of the business data modes and the difference of encoding personnel, a set of uniform specification is difficult to form in the process of encoding the intelligent contract code. Moreover, the block chaining technology is chained data storage, and has certain limitation on data management. For example, the method has the disadvantages of low data query efficiency, no support for list query and the like.
Disclosure of Invention
Aiming at the problems of lack of standardization in the actual development process of the intelligent contract and the limitation of data management of a block chain platform, the invention provides a method for automatically generating the block chain intelligent contract based on a database data table, which generates an intelligent contract code through a table structure of the database data table, unifies the specification of the intelligent contract code, simplifies the development process of the intelligent contract and improves the development efficiency; by synchronizing the data of the block chain platform into the database, the data visualization management is realized, and the data management efficiency is improved.
The purpose of the invention is realized by the following technical scheme: a method for automatically generating a block chain intelligent contract based on a database data table comprises the following steps:
(1) and creating a data table required by the service data in the relational database, wherein the table structure of the data table defines a table name, a table field type, a table field length, a table primary key and the like.
(2) Automatically generating an intelligent contract code according to a data table in a relational database, which specifically comprises the following steps: adding a corresponding structural body in the intelligent contract according to a data table structure in the relational database; adding a mapping relation of a corresponding structural body and an index in an intelligent contract according to a main key of a data table in a relational database; and simultaneously, according to the table structure and the table main key of the relational database, corresponding data adding, deleting, updating and querying functions are added in the intelligent contract.
(3) After the intelligent contract code is updated, generating a contract updating completion flag file; when the block chain platform detects the marker file, compiling the updated intelligent contract code; after the intelligent contract code is compiled, the block chain platform adds 1 to the target version number in the configuration file; and the block chain platform detects that the target version number in the configuration file is greater than the current version number, and upgrades and deploys the compiled intelligent contract.
(4) According to the one-to-one mapping relation of the data relation between the blockchain platform and the relational database, synchronizing the data in the blockchain platform into a corresponding data table of the relational database, specifically: and the block chain platform synchronizes the newly added, deleted and updated data to the relational database according to the one-to-one mapping relation of the data relations.
Further, in the step (2), the mapping relationship between the structure and the index is specifically: the structure name is consistent with the data table name, the structure member is consistent with the data table field name, and the structure member type is determined by the data table field type and the table field length; the index is consistent with the table primary key in the data table.
Further, in the step (2), the functions of adding, deleting, updating and querying data in the contract are realized through the mapping relation between the structure and the index; the index is a mapping key and is consistent with a table main key in the data table, and the structure body is the value of the mapping key.
Further, in the step (2), the data adding, deleting and updating functions belong to the same function, and are named as "insert + table name"; the data query function is named as "get + table name".
Further, the step (3) is specifically as follows: after the intelligent contract is updated, generating a contract updating completion flag file named contract. When the block chain platform detects a contract/update file, the block chain platform compiles the intelligent contract code; adding 1 to a target version number target _ version in a hpc. The block chain platform detects the hpc.
Further, in the step (4), the data synchronization is realized through a one-to-one mapping relationship of data relationships between the blockchain platform and the relational database; and simultaneously when the data is written into the blockchain platform, the data in the blockchain platform is synchronously updated into the data table.
Further, in the step (4), the data is visually managed by synchronizing to the data in the relational database.
The invention has the beneficial effects that: the invention creates a data table in a relational database; and the block chain platform automatically generates the intelligent contract codes by reading the newly-added data table in the relational database. And after the intelligent contract codes are updated, performing automatic compilation and deploying the intelligent contract codes to the block chain platform. The blockchain platform synchronizes data to the relational database. The method of the invention provides a one-to-one mapping relation of data relations between the block chain platform and the relational database, realizes automatic compiling of intelligent contracts, visualizes the data of the block chain platform and realizes automatic synchronization of the data. The method is convenient for developers to write contracts, improves the efficiency and can also improve the management efficiency of data.
Drawings
FIG. 1 is a flow chart of a method for automatically generating intelligent contracts for blockchains based on database data tables;
FIG. 2 is a table of data in a relational database;
fig. 3 is a contract code generated by a data table.
Detailed Description
In order to make the aforementioned objects, features and advantages of the present invention comprehensible, embodiments accompanied with figures are described in detail below.
In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present invention, but the present invention may be practiced in other ways than those specifically described and will be readily apparent to those of ordinary skill in the art without departing from the spirit of the present invention, and therefore the present invention is not limited to the specific embodiments disclosed below.
As shown in fig. 1, the method for automatically generating a blockchain intelligent contract based on a database data table provided by the present application includes the following steps:
(1) creating a data table required by service data in a relational database (MySQL), wherein the table structure of the data table defines a table name, a table field type, a table field length, a table primary key and the like; an example of a data table in a relational database is shown in FIG. 2.
(2) Automatically generating an intelligent contract code according to a data table in a relational database, which specifically comprises the following steps: adding a corresponding structural body in the intelligent contract according to a data table structure in the relational database; adding a mapping relation of a corresponding structural body and an index in an intelligent contract according to a main key of a data table in a relational database; simultaneously, according to the table structure and the table main key of the relational database, adding corresponding data adding, deleting, updating and inquiring functions in the intelligent contract; an example of contract code generated by a data table is shown in FIG. 3.
The mapping relationship between the structure and the index is specifically as follows: the structure name is consistent with the data table name, the structure member is consistent with the data table field name, and the structure member type is determined by the data table field type and the table field length; the index is consistent with the table main key in the data table;
specifically, the functions of data addition, deletion, update and query in the contract are realized through the mapping relation between the structure and the index; the index is a mapping key and is consistent with a table main key in the data table, and the structure body is the value of the mapping key.
Specifically, the functions of data addition, deletion and update belong to the same function, and can be named as 'insert + table name'; the data query function may be named "get + table name".
(3) After the intelligent contract code is updated, generating a contract updating completion flag file; when the block chain platform detects the marker file, compiling the updated intelligent contract code; after the intelligent contract code is compiled, the block chain platform adds 1 to the target version number in the configuration file; and the block chain platform detects that the target version number in the configuration file is greater than the current version number, and upgrades and deploys the compiled intelligent contract. One implementation example is given below:
after the intelligent contract is updated, generating a contract update completion flag file, which can be named as contract. When the block chain platform detects a contract/update file, the block chain platform compiles the intelligent contract code; and after the intelligent contract code is compiled, adding 1 to a target version number target _ version in a hpc. (for example, the target _ version has a current number value of 120, and is modified to 121 after compilation is completed). The block chain platform detects the hpc.
(4) According to the one-to-one mapping relation of the data relation between the blockchain platform and the relational database, synchronizing the data in the blockchain platform into a corresponding data table of the relational database, specifically: and the block chain platform synchronizes the newly added, deleted and updated data to the relational database according to the one-to-one mapping relation of the data relations.
The data synchronization is realized through the one-to-one mapping relation of the data relation between the block chain platform and the relational database; and simultaneously when the data is written into the blockchain platform, the data in the blockchain platform is synchronously updated into the data table. And realizing visual management of data by synchronizing the data in the relational database.
The foregoing is only a preferred embodiment of the present invention, and although the present invention has been disclosed in the preferred embodiments, it is not intended to limit the present invention. Those skilled in the art can make numerous possible variations and modifications to the present teachings, or modify equivalent embodiments to equivalent variations, without departing from the scope of the present teachings, using the methods and techniques disclosed above. Therefore, any simple modification, equivalent change and modification made to the above embodiments according to the technical essence of the present invention are still within the scope of the protection of the technical solution of the present invention, unless the contents of the technical solution of the present invention are departed.
Claims (7)
1. A method for automatically generating a block chain intelligent contract based on a database data table is characterized by comprising the following steps:
(1) and creating a data table required by the service data in the relational database, wherein the table structure of the data table defines a table name, a table field type, a table field length and a table primary key.
(2) Automatically generating an intelligent contract code according to a data table in a relational database, which specifically comprises the following steps: adding a corresponding structural body in the intelligent contract according to a data table structure in the relational database; adding a mapping relation of a corresponding structural body and an index in an intelligent contract according to a main key of a data table in a relational database; and simultaneously, according to the table structure and the table main key of the relational database, corresponding data adding, deleting, updating and querying functions are added in the intelligent contract.
(3) After the intelligent contract code is updated, generating a contract updating completion flag file; when the block chain platform detects the marker file, compiling the updated intelligent contract code; after the intelligent contract code is compiled, the block chain platform adds 1 to the target version number in the configuration file; and the block chain platform detects that the target version number in the configuration file is greater than the current version number, and upgrades and deploys the compiled intelligent contract.
(4) According to the one-to-one mapping relation of the data relation between the blockchain platform and the relational database, synchronizing the data in the blockchain platform into a corresponding data table of the relational database, specifically: and the block chain platform synchronizes the newly added, deleted and updated data to the relational database according to the one-to-one mapping relation of the data relations.
2. The method for automatically generating a blockchain intelligent contract based on a database data table according to claim 1, wherein in the step (2), the mapping relationship between the structure and the index is specifically: the structure name is consistent with the data table name, the structure member is consistent with the data table field name, and the structure member type is determined by the data table field type and the table field length; the index is consistent with the table primary key in the data table.
3. The method for automatically generating intelligent contracts based on database data tables according to claim 1, wherein in the step (2), the functions of data addition, deletion, update and query in the contracts are realized through a mapping relation between a structure body and an index; the index is a mapping key and is consistent with a table main key in the data table, and the structure body is the value of the mapping key.
4. The method according to claim 1, wherein in the step (2), the functions of adding, deleting and updating data belong to the same function, and are named as "insert + table name"; the data query function is named as "get + table name".
5. The method for automatically generating a blockchain intelligent contract based on a database data table according to claim 1, wherein the step (3) is specifically as follows: after the intelligent contract is updated, generating a contract updating completion flag file named contract. When the block chain platform detects a contract/update file, the block chain platform compiles the intelligent contract code; adding 1 to a target version number target _ version in a hpc. The block chain platform detects the hpc.
6. The method for automatically generating intelligent contracts for blockchains based on database data tables according to claim 1, wherein in the step (4), the data synchronization is realized through a one-to-one mapping relationship of data relationships between blockchain platforms and relational databases; and simultaneously when the data is written into the blockchain platform, the data in the blockchain platform is synchronously updated into the data table.
7. The method for automatically generating intelligent contracts for block chains based on relational database table structures according to claim 1, wherein in the step (4), visual management of the data is realized by synchronizing the data in the relational databases.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010265355.9A CN111581181B (en) | 2020-04-07 | 2020-04-07 | Method for automatically generating intelligent contract of block chain based on database data table |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010265355.9A CN111581181B (en) | 2020-04-07 | 2020-04-07 | Method for automatically generating intelligent contract of block chain based on database data table |
Publications (2)
Publication Number | Publication Date |
---|---|
CN111581181A true CN111581181A (en) | 2020-08-25 |
CN111581181B CN111581181B (en) | 2021-06-29 |
Family
ID=72124398
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010265355.9A Active CN111581181B (en) | 2020-04-07 | 2020-04-07 | Method for automatically generating intelligent contract of block chain based on database data table |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111581181B (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111813441A (en) * | 2020-09-10 | 2020-10-23 | 腾讯科技(深圳)有限公司 | Intelligent contract issuing method and device, computer readable medium and electronic equipment |
CN112269836A (en) * | 2020-11-15 | 2021-01-26 | 北京物资学院 | Block chain intelligent contract generation and management system and implementation mechanism thereof |
CN112308716A (en) * | 2020-10-28 | 2021-02-02 | 深圳前海微众银行股份有限公司 | Block chain intelligent contract execution method, device, equipment and computer storage medium |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20160171051A1 (en) * | 2014-12-15 | 2016-06-16 | National Tsing Hua University | Synchronization system for transforming database and method thereof |
CN107729561A (en) * | 2017-11-09 | 2018-02-23 | 成都卓凡软件科技有限公司 | The method that the table handling of paired data storehouse is reversely given birth to based on database table structure |
CN107918666A (en) * | 2017-11-24 | 2018-04-17 | 中钞信用卡产业发展有限公司杭州区块链技术研究院 | Method of data synchronization and system on a kind of block chain |
CN108052321A (en) * | 2017-12-28 | 2018-05-18 | 杭州趣链科技有限公司 | A kind of method that block chain intelligence contract is automatically generated based on configuration information |
CN110704082A (en) * | 2019-09-25 | 2020-01-17 | 许昌许继软件技术有限公司 | Continuous integration method and system for monitoring platform |
-
2020
- 2020-04-07 CN CN202010265355.9A patent/CN111581181B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20160171051A1 (en) * | 2014-12-15 | 2016-06-16 | National Tsing Hua University | Synchronization system for transforming database and method thereof |
CN107729561A (en) * | 2017-11-09 | 2018-02-23 | 成都卓凡软件科技有限公司 | The method that the table handling of paired data storehouse is reversely given birth to based on database table structure |
CN107918666A (en) * | 2017-11-24 | 2018-04-17 | 中钞信用卡产业发展有限公司杭州区块链技术研究院 | Method of data synchronization and system on a kind of block chain |
CN108052321A (en) * | 2017-12-28 | 2018-05-18 | 杭州趣链科技有限公司 | A kind of method that block chain intelligence contract is automatically generated based on configuration information |
CN110704082A (en) * | 2019-09-25 | 2020-01-17 | 许昌许继软件技术有限公司 | Continuous integration method and system for monitoring platform |
Cited By (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111813441A (en) * | 2020-09-10 | 2020-10-23 | 腾讯科技(深圳)有限公司 | Intelligent contract issuing method and device, computer readable medium and electronic equipment |
CN111813441B (en) * | 2020-09-10 | 2021-02-02 | 腾讯科技(深圳)有限公司 | Intelligent contract issuing method and device, computer readable medium and electronic equipment |
WO2022052632A1 (en) * | 2020-09-10 | 2022-03-17 | 腾讯科技(深圳)有限公司 | Intelligent contract publishing method and apparatus, and computer-readable medium and electronic device |
CN112308716A (en) * | 2020-10-28 | 2021-02-02 | 深圳前海微众银行股份有限公司 | Block chain intelligent contract execution method, device, equipment and computer storage medium |
CN112308716B (en) * | 2020-10-28 | 2024-02-20 | 深圳前海微众银行股份有限公司 | Block chain intelligent contract executing method, device, equipment and computer storage medium |
CN112269836A (en) * | 2020-11-15 | 2021-01-26 | 北京物资学院 | Block chain intelligent contract generation and management system and implementation mechanism thereof |
CN112269836B (en) * | 2020-11-15 | 2023-07-04 | 北京物资学院 | Block chain intelligent contract generation and management system and implementation mechanism thereof |
Also Published As
Publication number | Publication date |
---|---|
CN111581181B (en) | 2021-06-29 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN111581181B (en) | Method for automatically generating intelligent contract of block chain based on database data table | |
CN108052321B (en) | Method for automatically generating intelligent contract of block chain based on configuration information | |
CN100498764C (en) | Synchronous data updating method | |
CN109508355A (en) | A kind of data pick-up method, system and terminal device | |
CN109472446B (en) | BIM model-based engineering budget estimate planning method | |
CN101727322B (en) | Method and device for optimizing bill of material management interface | |
CN104317974A (en) | Reconfigurable multi-source data importing method in ERP system | |
CN103049251B (en) | A kind of data base persistence layer device and database operation method | |
CN103810212A (en) | Automated database index creation method and system | |
CN105224377A (en) | A kind of method by metadata automatic generating software project code file and device | |
CN103995854A (en) | Equipment cross-version upgrading method and device | |
CN103092970A (en) | Database operation method and device | |
CN107016047A (en) | Document query, document storing method and device | |
CN112130891B (en) | Method and equipment for continuously deploying database | |
CN107526746A (en) | The method and apparatus of management document index | |
US20090049025A1 (en) | System and method for harvesting service metadata from an architecture diagram into a metadata repository | |
CN102375827A (en) | Method for fast loading versioned electricity network model database | |
CN114860727A (en) | Zipper watch updating method and device | |
CN103107919A (en) | Method and system for network resource modeling | |
CN107766519B (en) | Method for visually configuring data structure | |
CN102043853A (en) | Method and device for updating stored data | |
US20060184715A1 (en) | Method and system for exchanging description data between projects | |
CN108427572B (en) | Land survey database updating method and updating increment package generating method thereof | |
EP0422877A2 (en) | A method for invalidating access plans in a database system | |
CN107025110B (en) | Temporal modeling method based on software development elements and relations among elements |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
TR01 | Transfer of patent right |
Effective date of registration: 20220526 Address after: No. 1788, Hongning Road, Xiaoshan District, Hangzhou, Zhejiang 311200 Patentee after: CHINA ZHESHANG BANK Co.,Ltd. Patentee after: Yiqiyin (Hangzhou) Technology Co., Ltd Address before: No. 1788, Hongning Road, Xiaoshan District, Hangzhou, Zhejiang 311200 Patentee before: CHINA ZHESHANG BANK Co.,Ltd. |
|
TR01 | Transfer of patent right |