Skip to main content

Database

Konomi keeps every interaction in one custom table, {prefix}konomi_interactions. This page documents what a row means, and — because the table is created through the plugin lifecycle — how to install a table of your own the same way.

The interactions table

One row is one user's interaction with one entity, within one group.

ColumnTypeMeaning
idBIGINT UNSIGNED AUTO_INCREMENTPrimary key
entity_idBIGINT UNSIGNED NOT NULLPost id — the Axis::Entity column
user_idBIGINT UNSIGNED NOT NULLUser id — the Axis::User column
entity_typeVARCHAR(50) NOT NULLPost type of the entity
group_keyVARCHAR(50) NOT NULLInteraction kind, e.g. reaction, bookmark

Keys:

  • PRIMARY KEY (id)
  • UNIQUE KEY entity_user_group (entity_id, user_id, group_key) — one row per (entity, user, group).
  • KEY user_group (user_id, group_key) — makes user-axis lookups fast.

The two indexes are the reason the same interaction can be read cheaply from either axis: the unique key serves entity lookups, the secondary key serves user lookups. This is the physical side of the axis model in Storage; Storage\TableStorage is the reader/writer.

  • Storage — the service that reads and writes this table, and the axis-to-column mapping.
  • Activation — how Konomi drives its own table's lifecycle, and the Activable contract.
  • Post / User — the domains whose interactions this table stores.