Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to design database for binary tree? [duplicate]

I'm doing a project in the field of multilevel marketing on .Net and SQL server. In the database it should save like a binary tree. How should i design a database?

like image 372
anishMarokey Avatar asked Jul 15 '09 05:07

anishMarokey


People also ask

What is the data structure of binary tree?

Binary Tree Data Structure. A tree whose elements have at most 2 children is called a binary tree. Since each element in a binary tree can have only 2 children, we typically name them the left and right child. A Binary Tree node contains following parts.

How to add multiple keys to a binary search tree?

A Simple Solution is to allow same keys on right side (we could also choose left side). For example consider insertion of keys 12, 10, 20, 9, 11, 10, 12, 12 in an empty Binary Search Tree A Better Solution is to augment every tree node to store count together with regular fields like key, left and right pointers.

What is a B-tree data structure?

B-Tree is a self-balancing tree data structure that maintains sorted data and allows searches, but it generalizes the binary search tree, allowing for nodes with more than two children.

How to add counts to a binary search tree?

A Better Solution is to augment every tree node to store count together with regular fields like key, left and right pointers. Insertion of keys 12, 10, 20, 9, 11, 10, 12, 12 in an empty Binary Search Tree would create following.


1 Answers

id | parentid | name
---------------------
 1 | null     | node1
 2 | 1        | node2
 3 | 1        | node3
like image 165
Arsen Mkrtchyan Avatar answered Sep 28 '22 03:09

Arsen Mkrtchyan