CREATE TABLE users ( id SERIAL PRIMARY KEY, username TEXT NOT NULL );
CREATE TABLE posts ( id SERIAL PRIMARY KEY, "user_id" INT REFERENCES users(id) NOT NULL,
content TEXT NOT NULL );
CREATE TABLE comments ( id SERIAL PRIMARY KEY, "post_id" INT REFERENCES posts(id),
"user_id" INT REFERENCES users(id), message TEXT );
INSERT INTO users (username) VALUES ('alice'), ('bob'), ('carol');
INSERT INTO posts ("user_id", content) VALUES (1, 'Post by Alice'), (2, 'Post by Bob');
INSERT INTO comments ("post_id", "user_id", message) VALUES
(1, 2, 'Bob comments on Alice''s post'), (2, 1, 'Alice comments on Bob''s post');
-- Add index on comments "post_id"
CREATE INDEX "idx_comments_post_id" ON comments("post_id");
The core of our platform, Ai agent built on N8N, is now open source
View on GitHubContact us: contact@isra36.com