0

我正在分析数据模式模型并使用它们进行一些概念验证测试。架构中有很多递归,我认为这可能会影响性能,因为每天会查询数千次数据,但树形结构基表上的信息只会每 X 天编辑一次。

架构中的一个表是 PRODUCT CATEGORY 汇总表,并且与 CATEGORY 具有 to 和 from 关系。

它可以用来保存记录器树结构(没有递归)吗?维护它们的最佳方法是什么?

4

1 回答 1

2

If you have limited tree structure (levels not more than e.g. 10 and amount of children is not more than 1000) you can use char level representation and inheritance. Each node or leaf is represented by some string. Each level down increases length of the string by 3

E.g. you have

ROOT
-CHILD 1
--subchild 1 of child 1
--subchild 2 of child 1
-CHILD 2
--subchild 1 of child 2
--subchild 2 of child 2

You have a 'tree_string' for them

ROOT - '000'
CHILD 1 - '000 000'
CHILD 2 - '000 001'
subchild 1 of child 1 - '000 000 000'
subchild 2 of child 1 - '000 000 001'
subchild 1 of child 2 - '000 001 000'
subchild 2 of child 2 - '000 001 001'

Thus with the string it's easy to get all subtree using tree_string LIKE parent_string_param%

于 2013-07-11T07:15:55.637 回答