hierarchy

CTE to traverse back up a hierarchy?

≡放荡痞女 提交于 2019-11-27 11:58:46
问题 I can find all the children of a given record in a hierarchical data model (see code below) but I'm not sure how to traverse back up the Parent/Child chain with a given Child ID. Can anyone point me in the right direction to figure out how to do this? Is this possible in Linq to SQL as well? WITH TaskHierarchy (TaskID, [Subject], ParentID, HierarchyLevel, HierarchyPath) AS ( -- Base case SELECT TaskID, [Subject], ParentID, 1 as HierarchyLevel, CONVERT(VARCHAR(MAX),'/') AS HierarchyPath FROM

Getting hierarchy data from self-referencing tables

情到浓时终转凉″ 提交于 2019-11-27 11:15:40
问题 Let's say you have the following table: items(item_id, item_parent) ... and it is a self-referencing table - item_parent refers to item_id . What SQL query would you use to SELECT all items in the table along with their depth where the depth of an item is the sum of all parents and grand parents of that item. If the following is the content of the table: item_id item_parent ----------- ----------- 1 0 2 0 3 2 4 2 5 3 ... the query should retrieve the following set of objects: {"item_id":1,

Flatten Adjacency List Hierarchy To A List Of All Paths

喜欢而已 提交于 2019-11-27 10:03:55
问题 I have a Table that stores Hierarchical information using the Adjacency List model. (uses a self referential key - example below. This Table may look familiar): category_id name parent ----------- -------------------- ----------- 1 ELECTRONICS NULL 2 TELEVISIONS 1 3 TUBE 2 4 LCD 2 5 PLASMA 2 6 PORTABLE ELECTRONICS 1 7 MP3 PLAYERS 6 8 FLASH 7 9 CD PLAYERS 6 10 2 WAY RADIOS 6 What is the best method to "flatten" the above data into something like this? category_id lvl1 lvl2 lvl3 lvl4 ----------

How to implement hierarchical multilevel datatable in javaScript?

我与影子孤独终老i 提交于 2019-11-27 09:39:22
I am implementing multi level datatable without using any plugin or library. I want to implement based on javaScript, JQuery or angular js. I checked one below links, Traverse all the Nodes of a JSON Object Tree with JavaScript nested table using ng-repeat But my json structure is different from above link. I need to display my JSON in Tree Structure UI. I don't hard code level in html. All level should be handle by javascript. I have implemented jsfiddle: http://jsfiddle.net/varunPes/0n9fmawb/40/ JSON STRUCTURE [ { Home:{ "checkbox_view":true, "checkbox_edit":false, "checkbox_delete":true } }

SQL Server: How to get all child records given a parent id in a self referencing table

ⅰ亾dé卋堺 提交于 2019-11-27 09:21:09
问题 Hi I have a table which references itself and I need to be able to select the parent and all it's child records from a given parent Id. My table is as follows: ID | ParentID | Name ----------------------- 1 NULL A 2 1 B-1 3 1 B-2 4 2 C-1 5 2 C-2 So for the above example I'd like to be able to pass in a value of 1 and get all the records above. So far, I've come up with the following recursive table-valued-function but it's not behaving as expected (only returning the first record). CREATE

MySQL - Recursing a tree structure

China☆狼群 提交于 2019-11-27 09:06:33
I have a database table which link locations together; a location can be in a location, which can be inside another location. location (<id>, ....) location_parent (<location_id>, <parent_id>) Here's the MySQL/PHP to go down for a depth of one: $sql = "SELECT id FROM se_locations_services WHERE parent_locationid IN ( SELECT location_id FROM se_locations_parent WHERE parent_id = '$locationid' )"; How do I, given a parent location, gets all its descendants locations, no matter how deep, just using MySQL? There's a good-looking article over at mysql.com outlining various ways of managing

Getting activity from context in android

爱⌒轻易说出口 提交于 2019-11-27 09:03:32
问题 This one has me stumped. I need to call an activity method from within a custom layout class. The problem with this is that I don't know how to access the activity from within the layout. ProfileView public class ProfileView extends LinearLayout { TextView profileTitleTextView; ImageView profileScreenImageButton; boolean isEmpty; ProfileData data; String name; public ProfileView(Context context, AttributeSet attrs, String name, final ProfileData profileData) { super(context, attrs); ...... ..

PHP Create breadcrumb list of every value in nested array

吃可爱长大的小学妹 提交于 2019-11-27 08:52:52
问题 I have an array that looks like the following: [ 'applicant' => [ 'user' => [ 'username' => true, 'password' => true, 'data' => [ 'value' => true, 'anotherValue' => true ] ] ] ] What I want to be able to do is convert that array into an array that looks like: [ 'applicant.user.username', 'applicant.user.password', 'applicant.user.data.value', 'applicant.user.data.anotherValue' ] Basically, I need to somehow loop through the nested array and every time a leaf node is reached, save the entire

C++ exception handling in class hierarchies

大憨熊 提交于 2019-11-27 07:48:01
问题 In a hierarchy of exception classes, What is the correct ordering of catch statements so as to allow exceptions of more than one class from the hierarchy of exception classes to be caught? Is it most derived to the base or the base to most derived? 回答1: Most derived first. Handlers are matched in the order they appear, so you want the most specific ones first. 回答2: My answer is according to linux compiler and hopefully it should be true for all. The order of the catch depends on 2 factors: (1

What is a rootView?

戏子无情 提交于 2019-11-27 06:25:52
问题 Hello I'm new in Android and I've opened a project with the default template Master detail flow but I don't know what is a rootView . I've search on developer.android.com but I don't really understood it ... So if someone can explain me clearly what's this thing doing it would help me a lot. Thanks ! Edit : there is the code ! public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (getArguments().containsKey(ARG_ITEM_ID)) { mItem = DummyContent.ITEM_MAP.get