Skip to Content
Tables & SQLChoosing Table Types

Choosing KalamDB Table Types

Choose a KalamDB table by who should see its rows and how long its data should live.

TableUse forExample
USERPrivate per-user dataNotes, personal inbox
SHAREDCollaborative data with policiesTeams, chat rooms
STREAMShort-lived, user-scoped realtime dataTemporary progress, transient events

Create a private KalamDB table

Run this as an account allowed to create tables, or add it to your project’s schema:

SQL
CREATE SCHEMA IF NOT EXISTS app; CREATE TABLE app.todos (  id BIGSERIAL PRIMARY KEY,  title TEXT NOT NULL,  completed BOOLEAN NOT NULL DEFAULT FALSE) WITH (TYPE = 'USER'); INSERT INTO app.todos (title) VALUES ('Build my first realtime app');SELECT * FROM app.todos;

Expect one row in your current user’s scope, with completed set to FALSE. Another authenticated user sees their own rows. You do not need to add a user_id predicate to every query.

When to choose SHARED or STREAM

Use SHARED when people need to see the same rows. Configure policies deliberately: regular users and services need a matching policy, while administrative roles bypass RLS.

Use STREAM for temporary events. Specify TTL_SECONDS at creation. STREAM rows are user-scoped; a stream is not automatically a shared broadcast channel.

Common mistakes

Test isolation with two normal users, not only with an administrator. A USER table read follows the effective identity even for root. A SHARED table needs policies before ordinary users can access its rows.

Next step

Query and modify your todos →

Reference: Table creation and options.