How can I store data in a table as a trie? (SQL Server)

為{幸葍}努か 提交于 2019-12-05 02:15:31

问题


To make things easier, the table contains all the words in the English dictionary.

What I would like to do is be able to store the data as a trie. This way I can traverse the different branches of the trie and return the most relevant result.

First, how do I store the data in the table as a trie?

Second, how do I traverse the tree?

If it helps at all, the suggestion in this previous question is where this question was sparked from.

Please make sure it's SQL we're talking about. I understood the Mike Dunlavey's C implementation because of pointers but can't see how this part (The trie itself) works in SQL.

Thanks,
Matt


回答1:


You model your data hierarchies with SQL Server 2008 using hierarchy id. See this MSDN magazine reference.



来源:https://stackoverflow.com/questions/2926790/how-can-i-store-data-in-a-table-as-a-trie-sql-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!