begin transaction;

create table newsgroup (
    id          INTEGER PRIMARY KEY NOT NULL,
    created_on  DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    name        TEXT NOT NULL,
    description TEXT NOT NULL
);

create table newsgroup_message (
    id           INTEGER PRIMARY KEY NOT NULL,
    newsgroup_id INTEGER NOT NULL,
    message_id   TEXT NOT NULL UNIQUE,
    created_on   DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    sender       TEXT NOT NULL,
    subject      TEXT NOT NULL,
    content      TEXT NOT NULL,

    FOREIGN KEY(newsgroup_id) REFERENCES newsgroup(id)
);

commit;
