views:

39

answers:

1

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.

A: 

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
dfens