スライドhttp://www.slideshare.net/billkarwin/models-for-hierarchical-dataで、SQLコード(22ページ)を見ました。
INSERT INTO Comments (author, comment)
VALUES (‘Ollie’, ‘Good job!’);
SELECT path FROM Comments
WHERE comment_id = 7;
UPDATE Comments
SET path = $parent_path || LAST_INSERT_ID() || ‘/’
WHERE comment_id = LAST_INSERT_ID();
私たちはそれを最適化できると思います:
SELECT path FROM Comments
WHERE comment_id = 7;
INSERT INTO Comments (author, comment, path )
VALUES (‘Ollie’, ‘Good job!’, $parent_path || LAST_INSERT_ID() || ‘/’);
私は正しいですか?