简体   繁体   English

区块链可以存储在 SQL 甚至 noSQL 数据库中吗?

[英]Can blockchain be stored in SQL or even noSQL database?

I have read that:我读过:

The blockchain database isn't stored in any single location, meaning the records it keeps are truly public and easily verifiable.区块链数据库不存储在任何单一位置,这意味着它保存的记录是真正公开的且易于验证。 No centralized version of this information exists for a hacker to corrupt.不存在可供黑客破坏的此信息的集中版本。 Hosted by millions of computers simultaneously, its data is accessible to anyone on the internet.由数百万台计算机同时托管,互联网上的任何人都可以访问其数据。

So my question is can we store blockchain in for example sql?所以我的问题是我们可以将区块链存储在例如 sql 中吗? or it can only be stored in a database that works on its own?或者它只能存储在独立工作的数据库中?

Currently decentralized blockchain applications have few options to store data.目前去中心化的区块链应用程序几乎没有存储数据的选项。 Decentralized storage options are:去中心化存储选项有:

  • Storing everything in blockchain itself将所有内容存储在区块链本身中
  • Peer to peer file system, such as IPFS Decentralized cloud file storages, such as Storj, Sia, Ethereum Swarm, etc.点对点文件系统,如 IPFS 去中心化的云文件存储,如 Storj、Sia、Ethereum Swarm 等。
  • Distributed Databases, such as Apache Cassandra, Rethink DB, etc.分布式数据库,如 Apache Cassandra、Rethink DB 等。
  • BigChainDB大链数据库
  • Ties DB关系数据库

Let's consider them all in detail:让我们详细考虑它们:

  1. Storing everything in blockchain itself : Storing everything in blockchain is the simplest solution.将所有内容存储在区块链本身中:将所有内容存储在区块链中是最简单的解决方案。 Currently most of the simple decentralized applications work exactly this way.目前,大多数简单的去中心化应用程序都以这种方式工作。 However, this approach has significant drawbacks.然而,这种方法有明显的缺点。 First of all transactions to blockchain are slow to confirm.首先,区块链的交易确认很慢。 It may seem to be fast for money transfer (anyone can wait a minute), but it is extremely slow for a rich application data flow.转账似乎很快(任何人都可以等一下),但对于丰富的应用程序数据流来说却是极其缓慢的。 Rich application may require many thousands transactions per second.丰富的应用程序每秒可能需要数千个事务。 Secondly, it is immutable.其次,它是不可变的。 The immutability is the strength of blockchain that gives it high robustness but it is a weakness for a data storage.不变性是区块链的强项,赋予其高稳健性,但它是数据存储的弱点。 User may change their profile or replace their photo, still all the previous data will sit in blockchain forever and can be seen by anyone.用户可以更改他们的个人资料或更换他们的照片,但所有以前的数据仍将永远存在于区块链中,任何人都可以看到。 The immutability results in one more drawback - the capacity.不变性导致了另一个缺点——容量。 If all the applications would keep their data in blockchain, the blockchain size will grow rapidly, exceeding publicly available hard drive capacity.如果所有应用程序都将其数据保存在区块链中,则区块链大小将迅速增长,超过公开可用的硬盘容量。 Full nodes can require special hardware.完整节点可能需要特殊硬件。 It may result in dangerous centralization of blockchain.它可能导致区块链危险的中心化。 That's why storing data in blockchain only is not a good option for a rich decentralized application.这就是为什么仅将数据存储在区块链中对于丰富的去中心化应用程序来说不是一个好的选择。
  2. Peer to peer file system, such as InterPlanetary File System .对等文件系统,例如 InterPlanetary File System IPFS allows to share files on client computers and unites them in the global file system. IPFS 允许在客户端计算机上共享文件并将它们统一在全局文件系统中。 The technology is based on BitTorrent protocol and Distributed Hash Table.该技术基于 BitTorrent 协议和分布式哈希表。 There are several good moments.有几个美好的时刻。 It is really peer to peer - to share anything first put it on your own computer.它真的是点对点的 - 分享任何东西首先把它放在你自己的电脑上。 It will be downloaded only if anyone needs it.只有在有人需要时才会下载它。 It is content addressable, so it is impossible to forge content by the given address.它是内容可寻址的,因此不可能通过给定的地址伪造内容。 Popular files can be downloaded very quickly thanks to BitTorrent protocol.借助 BitTorrent 协议,可以非常快速地下载流行文件。 However it also has some drawbacks.然而,它也有一些缺点。 You should stay online if you want to share your files.如果您想共享您的文件,您应该保持在线状态。 At least before someone becomes interested and wants to download them from you.至少在有人感兴趣并想从您那里下载它们之前。 It serves only static files, they can not be modified or removed once uploaded.它只提供静态文件,一旦上传就不能修改或删除。 And of course you can not search these files by their meaningful content.当然,您不能通过其有意义的内容来搜索这些文件。
  3. Decentralized cloud file storages : There are also decentralized cloud file storages that lift some of IPFS limitations.去中心化的云文件存储:还有去中心化的云文件存储可以解除一些 IPFS 的限制。 From the user's point of view these storages are just cloud storages like Dropbox, for example.从用户的角度来看,这些存储只是像 Dropbox 这样的云存储。 The difference is that the content is hosted on user's computers who offer their hard drive space for rent, rather than in datacenters.不同之处在于,内容托管在提供硬盘空间出租的用户计算机上,而不是托管在数据中心。 There are plenty of such projects nowadays.现在有很多这样的项目。 For example, Sia, Storj, Ethereum Swarm.例如,Sia、Storj、以太坊 Swarm。 You don't need to stay online to share your files anymore.您不再需要保持在线来共享您的文件。 Just upload the file and it is available in the cloud.只需上传文件,它就可以在云中使用。 These storages are highly reliable, fast enough, have enormous capacity.这些存储高度可靠,速度足够快,容量巨大。 Still they serve static files only, no content search anyway and, since they are built on the rented hardware, they are not free.它们仍然只提供静态文件,无论如何都没有内容搜索,而且由于它们是建立在租用的硬件上的,所以它们不是免费的。
  4. Distributed Databases : Since we need to store structured data and seek for advanced query capabilities we may look at the distributed noSql databases.分布式数据库:由于我们需要存储结构化数据并寻求高级查询功能,我们可以查看分布式 noSql 数据库。 Why noSql?为什么没有Sql? Because strict transactional SQL databases can not be truly distributed due to the restrictions of the CAP-theorem.因为受限于CAP-theorem的限制,严格的事务性SQL数据库无法真正实现分布式。 To make a database distributed we must sacrifice either consistency or availability.为了使数据库分布式,我们必须牺牲一致性或可用性。 NoSQL databases choose availability over consistency replacing it with so called “eventual consistency” where all the database nodes in the network become consistent some time later. NoSQL 数据库选择可用性而不是一致性,将其替换为所谓的“最终一致性”,即网络中的所有数据库节点在一段时间后变得一致。 There are many mature realizations of such databases, for example MongoDB, Apache Cassandra, RethinkDB and so on.此类数据库有很多成熟的实现,例如MongoDB、Apache Cassandra、RethinkDB等。 They are very good - fast, scalable, fault tolerant, support rich query language but still have fatal drawback for our application.它们非常好——快速、可扩展、容错、支持丰富的查询语言,但对于我们的应用程序仍然有致命的缺点。 They are not Byzantine-proof.它们不是拜占庭证明的。 All the nodes of the cluster fully trust each other.集群的所有节点相互完全信任。 So any malicious node can destroy the whole database.所以任何恶意节点都可以破坏整个数据库。
  5. BigChainDB : There is another project called BigChainDB that claims to solve the data storage and transaction speed problem. BigChainDB :还有一个叫 BigChainDB 的项目,声称解决了数据存储和交易速度问题。 It is also a blockchain but with enormous data capacity and really fast transactions.它也是一个区块链,但具有巨大的数据容量和非常快速的交易。 Let us see how it is possible.让我们看看它是如何可能的。 BigChainDB is build upon RethinkDB cluster, I mentioned this NoSQL database on the previous slide. BigChainDB 建立在 RethinkDB 集群之上,我在上一张幻灯片中提到了这个 NoSQL 数据库。 BigChainDB uses it to store all the blocks and transactions. BigChainDB 使用它来存储所有区块和交易。 That is why it shows such a high throughput - it is the one of the underlying noSQL database.这就是为什么它显示出如此高的吞吐量 - 它是底层 noSQL 数据库之一。 All the BigChainDB nodes (denoted BDB on the slide) are connected to the cluster and have full write access to the database.所有 BigChainDB 节点(在幻灯片上表示为 BDB)都连接到集群并且对数据库具有完全写入权限。 Here comes a problem - the whole BigChainDB is not byzantine-proof!问题来了——整个 BigChainDB 不是拜占庭证明的! Any malicious BDB node can destroy the RethinkDB cluster.任何恶意的 BDB 节点都可以破坏 RethinkDB 集群。 The BigChainDB team is aware of this problem and promises to solve it sometime in the future, however it is the corner stone of the architecture and changing it may not be possible.Anyway, BigChainDB may be good for a private blockchain. BigChainDB 团队意识到了这个问题,并承诺在未来的某个时候解决它,但它是架构的基石,改变它可能是不可能的。无论如何,BigChainDB 可能对私有区块链有好处。 But in my opinion, to avoid confusion it should have been named BigPrivateBlockchain.但在我看来,为了避免混淆,它应该被命名为 BigPrivateBlockchain。 It is not an option for a public storage.它不是公共存储的选项。
  6. Ties DB : The currently available options could be a good public database. Ties DB :当前可用的选项可能是一个很好的公共数据库。 The closest to the ideal are the noSql databases.最接近理想的是 noSql 数据库。 The only thing they lack is byzantine fault tolerance.他们唯一缺乏的是拜占庭容错。 The Ties.Network Database: ties.network is a deep modification of the Cassandra database and offers a preferable solution: The TiesDB inherits the majority of features from the underlying noSQL databases and adds byzantine fault tolerance and incentives. Ties.Network 数据库:ties.network 是对 Cassandra 数据库的深度修改,并提供了一个更好的解决方案:TiesDB 继承了底层 noSQL 数据库的大部分功能,并添加了拜占庭容错和激励机制。 With these features it can become a public database and enable feature-rich applications on Ethereum and other blockchains with smart contracts.凭借这些功能,它可以成为一个公共数据库,并通过智能合约在以太坊和其他区块链上启用功能丰富的应用程序。 The database is writable by any user.该数据库可由任何用户写入。 But the users are identified by their public key and all the requests are signed.但是用户是通过他们的公钥来识别的,所有的请求都被签名了。 Once created, record remembers its creator who becomes an owner of the record.一旦创建,记录就会记住成为记录所有者的创建者。 After that the record can be modified only by the owner.之后,该记录只能由所有者修改。 Everyone can read all records, because the database is public.每个人都可以读取所有记录,因为数据库是公开的。 All the permissions are checked on request and replication.根据请求和复制检查所有权限。 Additional permissions can be managed via a smart contract.可以通过智能合约管理其他权限。

source: here来源: 这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM