Skip to content

Instantly share code, notes, and snippets.

@vivainio
Created December 18, 2011 11:32
Show Gist options
  • Save vivainio/1493084 to your computer and use it in GitHub Desktop.
Save vivainio/1493084 to your computer and use it in GitHub Desktop.
drop table if exists blobs;
CREATE TABLE blobs (
id INTEGER PRIMARY KEY,
format INTEGER,
data BLOB
);
drop table if exists nodes;
CREATE TABLE nodes (
id INTEGER PRIMARY KEY,
gnx VARCHAR(20),
h TEXT,
bodyid INTEGER REFERENCES blobs(id)
);
-- 0 is always root node
INSERT INTO nodes (id, h) values (0, '__INVISIBLE_ROOT__');
drop table if exists edges;
CREATE TABLE edges (
a INTEGER NOT NULL REFERENCES nodes(id),
b INTEGER NOT NULL REFERENCES nodes(id),
pos INTEGER NOT NULL,
PRIMARY KEY (a, b, pos)
);
CREATE INDEX a_idx ON edges (a);
CREATE INDEX b_idx ON edges (b);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment