0

Blockchain can not store and shall not be used to store all the data of users. There are 2 reasons for that -

1) To store data in blockchain requires gas price (transaction cost)

2) Since all blocks are replicated on all the nodes participating in blockchain there are some limitations for storing big data in blockchain.

Blockchain is not replacement of a database but it is another layer on top of that to store transactions which are crucial for business and to ensure trust among multiple entities.

I read that remaining data shall be stored in IPFS and hash of that data is stored in blockchain. But as IPFS only supports unstructured data i.e. images and videos.

I want to store remaining user data in MongoDB and I will store hash of MongoDB document in blockchain. I shall be able to retrieve data stored in document from hash that is stored in blockchain. Are there any resources or tutorials available for implementing the same?

1

I recently build a tool to store, index and search content on IPFS called IPFS-Store and I'm using my tool to store and index JSON document (MongoDB style) but you an use it to index any type of content.

The service expose a REST API which accept any type of content, so you can basically push and pull JSON document.

For instance

curl -X POST \
  http://localhost:8040/ipfs-store/store \
  -H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
  -F 'file={"attribute1": "my json file to store on IPFS", "attribute2": "val2", "attribute3": 10}'

I'm planning to provide support for SWARM in the future.

  • Using above approach every record of a user will be stored as a separate json file. I will be able to store and retrieve user data but I won't able to query user data. Do you know how to extract and load existing data (from any SQL or NoSQL database) to swarm and how to query it ? – Soham Lawar Apr 26 '18 at 6:37
  • Do I need to use json query language (JSONiq) to query data stored in JSON files. – Soham Lawar Apr 26 '18 at 9:54
  • 1
    You could basically write one file per user on IPFS, index some attributes on elasticsearch and then use the search (and its own query language, see doc) to search users and retrieve users. – Greg Jeanmart Apr 26 '18 at 22:33
1

If you chose to go the MongoDB way, you'll lose some of your dApp's decentralization, because MongoDB needs to be hosted by somebody.

Another approach would be to use Ethereum's Swarm, which is part of Ethereum's ecosystem.

  • Are there any tutorials / blogs available which will help me to store user data in swarm ? – Soham Lawar Apr 25 '18 at 7:33
  • their official documentation is a really good start for that. – Tudor Constantin Apr 25 '18 at 7:39
  • 2
    Swarm proof-of-concept version 3 is right around the corner. The documentation is currently getting a big overhaul. So maybe hold off for a week or two if you're just getting into it. On topic: For inspiration here's a stub I wrote to demonstrate how to use sqlite's virtual file system functionality with swarm as backend (the swarm "block size" is 4096, same as sqlite's default) github.com/nolash/swarm-sqlite-vfs There's also a swarmdb initiation; to build a database on top of swarm directly. wolk.com are working on that. – lash Apr 25 '18 at 21:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.