Table structure
  • 13 Apr 2022
  • 2 Minutes to read
  • Contributors
  • Dark
    Light
  • PDF

Table structure

  • Dark
    Light
  • PDF

Article summary

The table in your Tenant is constructed using a single-table design pattern, where the items or rows in the table may be super-wide but very sparse.

Specifically, the table defines the following fields. Additional fields that you store per item are entirely up to you.

Fields

FieldTypeDescriptionRequired
pkStringThe partition or hash key for the tableY
skStringThe sort or range key for the tableY
lsi0_skStringThe sort or range key for the index lsi0N
lsi1_skStringThe sort or range key for the index lsi1N
lsi2_skStringThe sort or range key for the index lsi2N
lsi3_skStringThe sort or range key for the index lsi3N
lsi4_skStringThe sort or range key for the index lsi4N
ttlNumberThe Time-To-Live for the item, in Unix epoch time formateN
  • It is strongly recommended that you do not assign any meaning to the pk or various sk fields, and that each of these fields is effectively a copy of a meaningful field that you add to the item.
  • While the ttl is optional, EchoStream strongly recommends that you use it. It allows your table to automatically clean up old items. You will pay for all items in the table, even those you have lost reference to, and automatic cleanup mitigates this.

Indexes

IndexKeysUse
tablepk plus skThe primary table index. Supports discrete GetItem calls as well as Query calls
lsi0pk plus lsi0_skA Local Secondary Index. Supports Query calls using the secondary sort key
lsi1pk plus lsi1_skA Local Secondary Index. Supports Query calls using the secondary sort key
lsi2pk plus lsi2_skA Local Secondary Index. Supports Query calls using the secondary sort key
lsi3pk plus lsi3_skA Local Secondary Index. Supports Query calls using the secondary sort key
lsi4pk plus lsi4_skA Local Secondary Index. Supports Query calls using the secondary sort key
  • The pk and sk, in combination, must be unique. If your pk is unique and you do not need the sk, put in a placeholder value for the sk.
  • Items in your table may provide any number of the lsiX_sk fields for the corresponding indexes, including providing none of them (and just using the table index).
  • You may have as many items that declare duplicate lsiX_sk fields as you wish. If you do this, your Query calls on the lsiX indexes will return multiple items.
  • It is strongly recommended that you use the indexes provided where possible. While Scan calls are allowed, they are expensive and slow.