Reading Assignment: Multi-Index Database API

Now that you know the basics about tables. Let’s get nitty gritty. Read through this page in the EOS developer documentation. Then answer the following questions.

  1. Why do we need to have persistant storage?
  2. What limitations are set on the primary key?
  3. What are the benefits of having iterators instead of a traditional key-value storage option?

Post your answers in this forum thread.

  1. So we can view saved data later
  2. It must be of type unsigned 64-bit integer
  3. You can create multiple views on a table
1 Like

1. Why do we need to have persistant storage?
Actions must exist in an action context, this context must exist in a memory space (ram), so it can have a valid point of start (set of instructions), since the only way to pass the state of a data on EOSIO is by having a persisted database to be compared within the new data that will be inserted. (blockchain persistant storage that allow to do not have duplicate objects?)

2. What limitations are set on the primary key?
the primary key of the object in the eosio::multi_index container must be a unique unsigned 64-bit integer. Its by rule stablished, the unsigned 64-bit integer will work has the unique ID on the index table.

3. What are the benefits of having iterators instead of a traditional key-value storage option?
Enables rich retrieval capabilities. Up to 16 secondary indices can be defined, each having its own way of ordering and retrieving table contents. This allow to retrieve multiple views on the same table, different value types if need it and other data.

1 Like