hierarchy

Clojure states within states within states

房东的猫 提交于 2019-12-04 16:52:17
问题 I'd love to hear what advice the Clojure gurus here have about managing state in hierarchies. I find I'm often using {:structures {:like {:this {:with {:many 'levels}} } } } and if I want to track changes in state at multiple levels, by throwing atoms around values (atom {:like (atom 'this)} ) , I find myself thinking this must be wrong. Is it generally better to use just one atom at the top level, and have none as values in a map ? 回答1: Don't use nested atoms in a data structure if at all

Retrieve all parent/child records from database on Laravel (hierarchical data)

霸气de小男生 提交于 2019-12-04 11:40:59
问题 I have the following simplified database table structure for a legacy tickets-like system. messages id INT parent_id INT content TEXT answer TEXT ... On a list, I show all the messages. When a message is clicked, I display its answer etc. The problem is, now I need to make a list structure of all parents and children related to this message, as well as the position of this message in the tree. How could I retrieve those from database? I'm using Laravel, but raw SQL would also help me find the

Drupal 7: Pathauto hierarchical taxonomy terms pattern

我怕爱的太早我们不能终老 提交于 2019-12-04 11:30:34
I have a Drupal 7.9 taxonomy vocabulary according to the following scheme: category-1 category-1 > subcategory-1-1 category-1 > subcategory-1-2 category-1 > subcategory-1-3 category-2 category-2 > subcategory-2-1 I want to reflect this taxonomy hierarchy in my page url path like category-1/subcategory-1-1/page-123 To achieve this I'm using the modul Pathauto version 7.x-1.0. but I don't know which pattern I have to use. Currently I'm using [node:%field_taxonomy%]/[node:title] but with this pattern the url path is just subcategory-1-1/page-123 , so the complete hierarchy isn't reflected. Is

Sql Hierarchy ID Sorting By Level

ぐ巨炮叔叔 提交于 2019-12-04 11:26:33
Is it possible to sort sql data in a hierarchy by it's hierarchy id, and then for each level sort it say alphabetically? So say we have an Employees Table that lists the organizational hierarchy based on the Employees ID You have Bob (5) who has Phil (17) and Charlie(28) Reporting to him, and Josie (6) has Tyler (15) and Mike (56) Reporting to her. If you sort it by HierarchyID it will look like: Bob (/5/) --Phil (/5/17/) --Charlie (/5/28/) Josie (/6/) --Tyler (/6/15/) --Mike (/6/56/) But It would probably make more sense to have it look like Bob --Charlie --Phil Josie --Mike --Tyler Is this

Parent/Child hierarchy tree view

这一生的挚爱 提交于 2019-12-04 09:51:03
I have a parents table looks like this CHILD_ID | PARENT_ID | NAME 1 | Null | Bill 2 | 1 | Jane 3 | 1 | Steve 4 | 2 | Ben 5 | 3 | Andrew Id like to get a result set like this Bill ---Jane ------Ben ---Steve ------Andrew I know I need to do a rank query to rank the levels and a self join but all I can find on the net is CTE recursion I have done this in Oracle before but not in MS SQL Bit hacky and can be improved but hopefully it shows the principle... ;with relation (childId, parentId, childName, [level], [orderSequence]) as ( select childId, parentId, childName, 0, cast(childId as varchar(20

Calculate the percentage of the root owned by its parents

大城市里の小女人 提交于 2019-12-04 09:12:50
问题 In simplified terms, I'm trying to calculate the percentage of the root of a tree owned by its parents, further up the tree. How can I do this in SQL alone? Here's my (sample) schema. Please note that though the hierarchy itself is quite simple there is an additional holding_id , which means that a single parent can "own" different parts of their child. create table hierarchy_test ( id number -- "root" ID , parent_id number -- Parent of ID , holding_id number -- The ID can be split into

Django project hierarchy/organization

不羁的心 提交于 2019-12-04 08:11:27
问题 I am new to Django and starting a project, and I would like to do it the right way. I would like to know what you think is best practice for organizing a project. Here are some questions I have: How do I separate the static resources from the Python code so that I don't waste time processing the static content through Django? As apps are reusable modules, they are not really tight to a project, so should they be located in the project directory, or in another directory that would contain all

How to use ‘hts’ with multi-level hierarchies?

不问归期 提交于 2019-12-04 07:59:43
I am forecasting on a large set of time series (5,000+). I would like to do this with a hierarchical approach were I do the forecasting at a higher level and then allocate the forecast down to each SKU. I see a need for doing this in order to zoom into a lower geographic level of detail, while doing the forecasting on a higher level (top-down). For example, below you see a sample of the structure that I am thinking about. Total => Europe => Netherlands => RegionA => Client_A_in_Netherlands => SKU1 => SKU2 => SKU3 => Client_Q_in_Netherlands => SKU15 => Germany1 => (...) => ClientY_in_Germany =>

How to populate a tree view based on a flat list with “levels”?

拈花ヽ惹草 提交于 2019-12-04 07:39:05
I have a list of objects populated from a third-party project file. The way this file was designed is so each item is on a "level" of hierarchy. So the very first item is on level 0, all of its child items are on level 1, and so on. As an example: 1. Node 1 (Level 0) 2. Node 1.1 (Level 1) 3. Node 1.2 (Level 1) 4. Node 1.3 (Level 1) 5. Node 1.3.1 (Level 2) 6. Node 1.4 (Level 1) 7. Node 2 (Level 0) 8. Node 2.1 (Level 1) 9. Node 2.1.1 (Level 2) 10. Node 3 (Level 0) This would produce a hierarchy like so: - Node 1 --- Node 1.1 --- Node 1.2 --- Node 1.3 ----- Node 1.3.1 --- Node 1.4 - Node 2 ---

Hierarchical Query Needs to Pull Children, Parents and Siblings

本小妞迷上赌 提交于 2019-12-04 07:34:13
Can now pull the data, but am wondering if there is a better way to optimize the query for large data sets. http://sqlfiddle.com/#!4/0ef0c/5 So basically I want to be able to supply the query a given org id and have it recursively pull its parents, its children, its siblings and its aunts and uncles. And then pull any Activities that are associated with that org hierarchy. Org1 is the top level org, but it may or may not have a null parent. Basically I was doing an up and down query to pull the children and the parent, but can only seem to get the siblings by adding another query. Finally got