How to create a database for a binary tree?

I am doing a multi-level marketing project on .Net and SQL server. In the database, it should save as a binary tree. How do I create a database?

+4
source share
3 answers

SQL Server 2008 has a built-in data type called hierarchyid for storing hierarchical information. Here are a few pointers.

And of course, you can do this as indicated by arsenmkrt in databases other than sqlserver2008.

+3
source

That was and answered before .

Here's a pretty decent tutorial that explains why the adjacency model proposed by arsenmkrt is less than ideal.

+4
source
id | parentid | name --------------------- 1 | null | node1 2 | 1 | node2 3 | 1 | node3 
+3
source

All Articles