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
  1. Why do we need to have persistent storage?
    This storage contains the EOS blockchain state and therefore must be available at all times. This includes the tables that hold order books, account balances, contract statuses and voting data.

  2. What limitations are set on the primary key?
    The primary key must be unique and an unsigned 64 bit integer type.

  3. What are the benefits of having iterators instead of a traditional key-value storage option?
    The main benefit is that they allow the code be less type dependant. The iterator will still work even if you change the underlying container type that is being iterated. Iterators are class objects which encapsulate safe node pointers that are only exposed via the iterator’s methods. Iterators can be used to provide differing table views where the table has multiple secondary indices.

1 Like
  1. So that we can check if the data is valid on the EOS blockchain

  2. The primary key must be unique and have an unsigned 64 bit integer type.

  3. We can retrieve multiple views of the same table

1 Like