in Postgres

Clojure – PostgreSQL Test DB

ref : https://github.com/briancarper/oyako/wiki/Example
[code]
CREATE TABLE category (
id integer PRIMARY KEY,
name text
);

CREATE TABLE tag (
id integer PRIMARY KEY,
name text
);

CREATE TABLE post (
id integer PRIMARY KEY,
title text,
content text,
category_id integer REFERENCES category (id)
);

CREATE TABLE comment (
id integer PRIMARY KEY,
post_id integer REFERENCES post (id),
content text
);

CREATE TABLE post_tag (
id integer PRIMARY KEY,
post_id integer REFERENCES post (id),
tag_id integer REFERENCES tag (id)
);
[/code]

[code]
INSERT INTO category VALUES (1, ‘Cows’);
INSERT INTO category VALUES (2, ‘Programming’);

INSERT INTO tag VALUES (1, ‘Current event’);
INSERT INTO tag VALUES (2, ‘Editorial’);
INSERT INTO tag VALUES (3, ‘Elucidation’);

INSERT INTO post VALUES (1, ‘Cows rule’, ‘Everyone likes cows, right?’, 1);
INSERT INTO post VALUES (2, ‘Clojure rocks’, ‘Everyone likes Clojure, right?’, 2);

INSERT INTO comment VALUES (1, 2, ‘Brian’, ‘Me too!’);

INSERT INTO post_tag VALUES (1, 1, 1);
INSERT INTO post_tag VALUES (2, 1, 3);
INSERT INTO post_tag VALUES (3, 2, 2);
INSERT INTO post_tag VALUES (4, 2, 3);

[/code]

Write a Comment

Comment

  • Related Content by Tag