1 # The main variations tree lives in table tree_node, referencing the current
2 # version of the nodes in tree_node_archive. Each node has a set of SGF nodes
3 # (sgf_node), set of attributed comments (node_comment), editorial comment
4 # and possibly other metadata later.
9 DROP TABLE tree_node_archive;
12 CREATE TABLE tree_node_archive (
13 id INT AUTO_INCREMENT PRIMARY KEY,
14 tree_pos INT NOT NULL,
15 FOREIGN KEY (tree_pos) REFERENCES tree_node (id),
17 # Also IPv6 addresses and other junk!
21 CREATE TABLE tree_node (
22 id INT AUTO_INCREMENT PRIMARY KEY,
23 parent INT DEFAULT NULL,
24 FOREIGN KEY (parent) REFERENCES tree_node (id) ON DELETE CASCADE,
27 FOREIGN KEY (version) REFERENCES tree_node_archive (id)
31 # Board-related SGF node
32 # This should be used only for trivial SGF nodes; any metadata should be
33 # stored in proper table columns.
34 CREATE TABLE sgf_node (
35 id INT AUTO_INCREMENT PRIMARY KEY,
38 FOREIGN KEY (tnode) REFERENCES tree_node_archive (id) ON DELETE CASCADE,
40 code VARCHAR(2) NOT NULL,
45 INSERT INTO tree_node_archive SET editorial="The Road Begins Here";
46 INSERT INTO tree_node SET version=1;