I'm looking for a way to store data in a decentralized way such that I can access any record from within the smart contract, probably through oracles I guess?
I've been looking into gundb but not sure how it can be used with solidity.
Ethereum Stack Exchange is a question and answer site for users of Ethereum, the decentralized application platform and smart contract enabled blockchain. It only takes a minute to sign up.Sign up to join this community
Storing data on the Ethereum chain can get very economically infeasible.
I would suggest making use of IPFS via Filecoin. This breaks your files up in objects, encrypts it and distributes/stores copies on different user's storage mediums without them having they encryption keys. IPFS will provide you a hash to "relocate" your data. For added safety, you can save that hash on the Ethereum chain.
If your idea is to store data directly on the Ethereum chain and the regain access to it via a Smart Contract, this can be done by a few lines of code but will be economically infeasible for even relatively small data. Thus the latter is proposed.
Hope this helps.
If you are ok with using (centralized) oracles then you can basically use any database alternative out there. Oracles provide access to the world outside blockchain so the oracle can just call any database you want - depending of course on what the oracle supports.
IPFS is quite popular for somewhat-decentralized data storage, for example.
In order to get data in or out of the blockchain in a decentralized manner, you'll need to use a decentralized blockchain oracle network.
As many have mentioned, storing a lot of data on-chain and using Ethereum as your database can be very expensive as a single user, and as such, other services such as IPFS are better suited as blockchain-based databases.
That being said, if you use the economy of scale with enough users, you can retrieve data from many independent Chainlink nodes and store data-on chain even cheaper than a centralized oracle. Chainlink is a technology built for decentralized oracle and data services.
This is what Chainlink has done with it's price feeds. This acts in a way as a database, as has a permanent record of prices of specific asset pairs, all being brought in by a network of decentralized oracles. You can access the current prices or historical (based on when it started running for the price pair).
This works because many entities are chipping in to pull data in a decentralized manner to create a community tool. This can be achieved for any data source to make it economically feasible, obviously, there just has to be enough interest.