CREATE TABLE users (
    id          INTEGER PRIMARY KEY AUTOINCREMENT,
    username    VARCHAR(64)  NOT NULL UNIQUE,
    email       VARCHAR(255) NOT NULL UNIQUE,
    password    CHAR(64)     NOT NULL,
    is_active   BOOLEAN      NOT NULL DEFAULT TRUE,
    role        VARCHAR(32)  NOT NULL DEFAULT 'user',
    created_at  TIMESTAMP    NOT NULL DEFAULT CURRENT_TIMESTAMP,
);

SELECT
    u.username,
    u.email,
    p.title
FROM users u
JOIN posts p ON p.author_id = u.id
WHERE u.is_active = TRUE
ORDER BY p.created_at DESC
LIMIT 20

SELECT * FROM;

CREATE INDEX ON posts(status);

INSERT INTO users (username, email, password)
VALUES ('alice', 'alice@example.com');

UPDATE posts
SET status = 'archived',
WHERE published_at < datetime('now', '-1 year');
