hierarchical-data

How to store a tree in SQL database

北城余情 提交于 2019-12-29 18:44:22
问题 I have to store a tree in a database, so what is the best way to do this? Show the method you use and name its pros and cons. (I am using SQL Server 2005) 回答1: I found the discussion in the SQL Anti-patterns very helpfull, as it also focuses on the drawbacks of every implementation. Also, The slides 48-77 in this presentation reiterate that analisys. Bottom line, there is no such thing as a generic tree, and no silver bullet for SQL trees. You'll have to ask yourself about the data, how and

How to store a tree in SQL database

ε祈祈猫儿з 提交于 2019-12-29 18:44:10
问题 I have to store a tree in a database, so what is the best way to do this? Show the method you use and name its pros and cons. (I am using SQL Server 2005) 回答1: I found the discussion in the SQL Anti-patterns very helpfull, as it also focuses on the drawbacks of every implementation. Also, The slides 48-77 in this presentation reiterate that analisys. Bottom line, there is no such thing as a generic tree, and no silver bullet for SQL trees. You'll have to ask yourself about the data, how and

MySQL parent -> child query

不打扰是莪最后的温柔 提交于 2019-12-29 07:21:29
问题 I'm working with mySQL, and I'm in a situation where I need to select data from one table that matches an ID at any level in parent -> child data hierarchy in the other table. Further more, I would like to resolve this with a well written SQL query, rather than a recursive function in my PHP code, as this feature will be used quite a bit. I did try searching, and I have stumbled upon numerous similar problems (most of them being resolved), however none of them helped me. To help illustrate

SQL tree traversal

我们两清 提交于 2019-12-29 07:11:09
问题 I am not totally sure I am naming this right, but please bear with me. I am wondering if is possible to do something like this in SQL(MySQL specifically): Let's say we have tree-like data that is persisted in the database in the following table: mysql> desc data_table; +------------------------+---------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +------------------------+---------------------+------+-----+---------+----------------+ |

Backbone with a tree view widget

孤者浪人 提交于 2019-12-29 02:45:46
问题 I'm evaluating the Backbone javascript framework for use in a project that will display a hierarchical model in a tree view widget (think the Windows file browser). I love how Backbone thinks about the world. However, there's a lot of coding involved before I get to a proof of concept that has Backbone actually receiving a hierarchical model from a server and updating a tree widget. I've seen there's various solutions for representing deep data structures with Backbone, but I'm wondering...

Create Tree Query From Numeric Mapping Table in SQL (With Seperator Field)

梦想的初衷 提交于 2019-12-26 03:54:10
问题 I have an exported table from my accounting software like below in SQL Server 2008. AccountID AccountName SourceCast --------- ----------- ----------- 11 Acc11 9401 12 Acc12 9401 13 Acc13 9401 11/11 Acc11/11 9401 11/12 Acc11/12 9401 11/111 Acc11/111 9401 11/11/001 Acc11/11/001 9401 11/11/002 Acc11/11/002 9401 15 Acc15 9402 12 Acc12 9402 13 Acc13 9402 15/15 Acc15/15 9402 15/12 Acc15/12 9402 15/111 Acc15/111 9402 15/15/001 Acc15/15/001 9402 15/15/002 Acc15/15/002 9402 Then expected result must

select all products and join main category through sub-categories (unknown level)

丶灬走出姿态 提交于 2019-12-25 08:13:50
问题 I have 2 tables Categories id - name - parent 1 - Category A - 0 2 - Category B - 0 3 - Category C - 0 4 - Category D - 0 5 - Subcategory Of 1 - 1 6 - Subcategory Of 5 - 5 7 - Subcategory Of 5 - 5 Product id - name - category - description 1 - Name - 5 - Description How to select all products and join main category through sub-categories? Product categories can has only 1 or 2 or 3 or 4 levels (Unknown level). I use "WITH RECURSIVE" in categories table but can't find the way to combine

select all products and join main category through sub-categories (unknown level)

廉价感情. 提交于 2019-12-25 08:10:04
问题 I have 2 tables Categories id - name - parent 1 - Category A - 0 2 - Category B - 0 3 - Category C - 0 4 - Category D - 0 5 - Subcategory Of 1 - 1 6 - Subcategory Of 5 - 5 7 - Subcategory Of 5 - 5 Product id - name - category - description 1 - Name - 5 - Description How to select all products and join main category through sub-categories? Product categories can has only 1 or 2 or 3 or 4 levels (Unknown level). I use "WITH RECURSIVE" in categories table but can't find the way to combine

Flatten (with level numbers) a hierarchical list

一世执手 提交于 2019-12-24 17:09:47
问题 I have a collection of class X instances that point to themselves (self-referencing). As an example, my class could look like this: public class X { string Name {get;set;} List<X> Children {get;} } Now lets say I have a list of instances of class X, which can self-reference themselves N levels down. My question is: How do get the instances of X from Nth level in my list? Basically I am trying to do in C# what a recursive self-referencing common table expression would do in SQL, which is to

Add children to HierarchicalCollectionView

南楼画角 提交于 2019-12-24 13:45:49
问题 I'm trying to implement lazy loading on ADG. and I'm stuck in the point where I need to add the returned children to the expanded node. Currently I'm doing: private function childrenloaded(data:*,item:*):void { var len:int = data.length; for(var i=0;i<len;i++) (internalMainGrid.dataProvider as HierarchicalCollectionView).addChild(item, data[i]); } This works fine, but it is slow. (21,990 ms for total: 919 records) is there some way I can speed this up? - like setting children directly Ex: var