How would one implement or use an SQL database in a contract? What would be the best practices for this? There could be a lot of data here, but I need to easily select and update.
EOS is first and foremost blockchain system that supports Database to share data among users. However there are some notes that may change your mind of thinking how that database looks like.
- This is in-memory database which means to be accessed by dapp. Note that EOS blocktime is 0.5 second so that executed time would be fast.
- It's permanently stored in blockchain, shared among nodes and be loaded in to RAM.
- It's implemented by serializable-like function so you can manipulate it the same way as objects.
- Ram is allocated to each user so Smart contract needs optimize how data is stored.
The OCI video shows exactly how to do select and update queries using the eosio::multi_index: