Here is my schema using sqlite, I am not sure if this is a good way to create tree structure in sql as I have to traverse many time to obtain the entire tree, as oppose to extracting the entire tree base on top comment and construct the tree in python. Can someone give me some suggestions.
BEGIN;
CREATE TABLE "tree_comment"
("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
"text" text NOT NULL,
"parent_id" integer NULL REFERENCES "tree_comment" ("id"));
CREATE INDEX "tree_comment_6be37982" ON "tree_comment" ("parent_id");
COMMIT;