开发者

how to represent a Binary Search Tree as a database schema?

开发者 https://www.devze.com 2023-01-20 02:16 出处:网络
I need to represent Binary Search Tree as a DB schema? How do I do it?开发者_运维技巧 Its kind of problem. I dont have any code. I need direction how to show BST as a DB schema.Sample:

I need to represent Binary Search Tree as a DB schema? How do I do it?开发者_运维技巧 Its kind of problem. I dont have any code. I need direction how to show BST as a DB schema.


Sample:

id   |    value   |   left_id  |   right_id   |   parent_id (optional)
1    |    100     |     2      |   3          |     NULL    
2    |    50      |   NULL     |   NULL       |   1
3    |    150     |   NULL     |   NULL       |   1

will represent:

  100
 /   \
50   150
0

精彩评论

暂无评论...
验证码 换一张
取 消