I come across a situation where i need to implement a relational database for an application. Now my question is how to implement it and where should i save the data? also i don't want to save data on RAM as it get very expensive when data size grows.
2 Answers
A good way would be to use the demux-js library. It listens for specified actions and allows updating logic for whatever kind of database you like. This is a RAM free option which essentially allows you to achieve CRUD functionality by creating a mirror image of what the blockchain would show if you played through all of your actions.
Mind the mess, but you can see me implement demux here.
-
blockchain is decentralized and so the data is just want to confirm by using demux the data will be centralized.is it good for a dapp? Sep 6, 2018 at 9:37
-
1Demux provides a mirror of the chain for ease of use. You can still verify on chain.– NatSep 6, 2018 at 9:40
-
that's great !! if i setup mongo db at my local server and do save data before every transaction ! is it good practice ? Sep 6, 2018 at 11:19
-
So inorder to run demux do i need to run my own node (nodeos) in develpment server. Oct 4, 2018 at 3:06
-
1@YashwanthKambala No, but you'll want to use a local node. "// Locally hosted node needed for reasonable indexing speed". You can also set the initial block that you want to listen for so you don't start at the first block. github.com/EOSIO/demux-js– NatOct 5, 2018 at 11:25
Another option is to use eosio mongodb_plugin for archive blockchain log into mongodb by running a node then apply queries on it.
https://developers.eos.io/eosio-nodeos/docs/mongo_db_plugin
@Nat i need your opinion about that option.
-
3It may be viable, but I think demux is more flexible because you can use almost every db you like.– tmm ♦Sep 6, 2018 at 7:59
-
Yeah, that one of plus point. we want to save data in decentralized database and give data ownership to user. is there any decentralized db who work well in that situation ?? Sep 6, 2018 at 8:03
-
1To be honest, I haven't touched that plugin. I'm still compiling contracts on 1.07 :). I'll update when the docs do. They're working hard at b1 right now and short handed in that department. I agree with TeeAttack42.– NatSep 6, 2018 at 8:16
-
Thank you so much Nat & TeeAttack42 for your quick response. That help us a lot. Sep 6, 2018 at 8:28