How to store directory / hierarchy / tree structur

2019-01-08 08:47发布

How do i store a directory / hierarchy / tree structure in the database? Namely MSSQL Server.

@olavk: Doesn't look like you've seen my own answer. The way i use is way better than recursive queries :)

p.p.s. This is the way to go!

8条回答
手持菜刀,她持情操
2楼-- · 2019-01-08 09:13

This is more of a bookmark for me than a question, but it might help you too. I've used this article's approach to store a directory / tree structure in the database.

There are some useful code snippets in the article as well.

Hope this helps.

I'm not affiliated with that website in any way

查看更多
Deceive 欺骗
3楼-- · 2019-01-08 09:13

The typical way is a table with a foreign key (e.g. "ParentId") onto itself.

查看更多
登录 后发表回答