create table dialogs( participant_1 integer not null, participant_2 integer not null, created_at timestamp not null, message_count integer not null default 0, primary key (participant_1, participant_2) ); create table dialog_messages( dialog_id integer not null, id integer not null, -- unique per dialog, sequential in one dialog content string not null, primary key (dialog_id, id) );