PaperScore的动态

PaperScore转发了

查看Daniel Armani, Ph.D.的档案

Data Scientist | Chief Scaffolder at PaperScore

Yes, blockchain is an append-only database, but no, we cannot simply build one with SQL. However, for educational purposes, I designed a relational database that imitates/simulates the Bitcoin Blockchain to some extent. It has four main tables: Accounts: This table stores the public keys of senders and receivers involved in transactions. It does not store balances but the database calculates balances dynamically by summing up UTXOs (unspent transaction outputs) from the Parties table. If we also store the balance of each account, it becomes more like the Ethereum blockchain. Transactions: This table records the value transfers between accounts. To mimic Bitcoin, each transaction can have multiple senders and multiple receivers. Thus, it has a many-to-many relationship with the Accounts table. Parties: This is the bridge table that establishes the many-to-many relationship between Transactions and Accounts. To track each party’s gain from and contribution to each transaction, each record has an amount (UTXO) that is positive for receivers and negative for senders. The sum of inflows can be more than the sum of outflows. The extra amount is the fee (tip) that goes to the miner. Blocks: Each block can have one miner and multiple transactions. The blocks are added one at a time and each block points to the previous block via the block hash. ---------- We also need to make the database immutable and tamper-proof. While anybody can read (SELECT) information from any table, the UPDATE and DELETE access are revoked for everyone, making the database append-only.?? REVOKE UPDATE, DELETE ON Blocks FROM PUBLIC; -- Repeat for every table. People can only add (INSERT) new data into the database. But, to prevent invalid entries, INSERT into the Transactions and Blocks tables are possible only via the stored procedures that enforce the blockchain protocol rules. Like Bitcoin, each new block is added by the user (the miner) who finds a valid nonce through a computationally intensive process (proof of work). The blockchain protocol specifies the rules that control how and what new data is added to the blockchain. It determines how and who judges the validity of the new entries. In short, a blockchain protocol is a constitution in computer code (e-constitution) as explained in the article?"Blockchain: The Quiet Revolution" (https://lnkd.in/efD2FkV6) Here is the complete code for our blockchain database: https://lnkd.in/e7JZHCPi Except it is not complete! It lacks some details, such as decentralization, network propagation, cryptographic validation, and millions of identical duplicates worldwide! Such features are not trivial to implement in a traditional SQL database. So don’t try this at home! If you have an idea to improve this code, feel free to fork this repository, clone it, make changes, test your changes locally, and then open a PR. Please explain your reasons in the PR. #blockchain #database #bitcoin #cryptocurrency #paralead #SQL _

  • Entity Relationship Diagram for the Database that Simulates a Blockchain
shervin kazemzadeh

Senior Software Developer | MEng,Artificial Intelligence| Payment Solutions | Blockchain Solutions

4 个月

Very helpful

查看更多评论

要查看或添加评论,请登录