hierarchy

How do I convert a relational hierarchy to a closure table in MySQL?

ぐ巨炮叔叔 提交于 2020-02-25 05:30:33
问题 I recently started using a closure table, and it was working fine when I had to convert simple parent-child relationships from person to lineage, but now I have to convert grandparent-parent-child and great-grandparent-parent-child relationships, and maybe even longer relationships than that into the closure table. This is the table I need to pull the relationships from: CREATE TABLE `person` ( `person` BIGINT UNSIGNED NOT NULL , `parent` BIGINT UNSIGNED NULL , PRIMARY KEY (`person`) , INDEX

Using a generic type of any nested subclass within its abstract superclass

人盡茶涼 提交于 2020-02-23 07:04:10
问题 Suppose you have the following abstract java class: public abstract class AbstractRequestHandler<I,O> { I input; O output; } and the following child classes hierarchy: public abstract class AbstractUserRequestHandler<I extends User,O> extends AbstractRequestHandler<I,O>{...} public abstract class AbstractUniversityRequestHandler<I extends UniversityUser> extends AbstractUserRequestHandler<I,String>{...} public class StudentRequestHandler extends AbstractUniversityRequestHandler<Student>{...}

What if the virtual destructor defined in derived class, but not the top of hierarchy? C++

戏子无情 提交于 2020-01-30 12:25:12
问题 I wonder is it correct to define a base class with no virtual destructor, and define inherited classes with the virtual one? What would actually happen if I do that? 回答1: If you delete p where p is of type X* but actually points to a Y which is derived from X , you have undefined behavior unless X has a virtual destructor. If Y 's destructor is virtual but X s destructor is not it changes exactly nothing. 回答2: If you intend to do delete pB; where pB is of type Base* and pB might point to an

Postgres Materialized Path - What are the benefits of using ltree?

左心房为你撑大大i 提交于 2020-01-24 20:36:06
问题 Materialized Path is a method for representing hierarchy in SQL. Each node contains the path itself and all its ancestors ( grandparent/parent/self ). The django-treebeard implementation of MP (docs): Each step of the path is a fixed length for consistent performance. Each node contains depth and numchild fields (fast reads at minimal cost to writes). The path field is indexed (with a standard b-tree index): The materialized path approach makes heavy use of LIKE in your database, with clauses

Hierarchical Span of Control report in SQL, without Oracle CONNECT BY syntax?

雨燕双飞 提交于 2020-01-24 16:15:19
问题 Summary Span of Control is a count of how many employees report to a given manager. Direct and indirect report counts should be split into their own totals. Other counts are needed, including many vacancies for direct and indirect reports there are in the organisation. A manager is any position that has other positions reporting to it. The reporting path from the top to anywhere in the tree is required to flatten the structure. I've seen this problem appear often in HR reporting and data

Sum of child levels total in a Hierarchy

若如初见. 提交于 2020-01-20 02:48:05
问题 I need to have each level be the sum of all children (in the hierarchy) in addition to any values set against that value itself for the Budget and Revised Budget columns. I've included a simplified version of my table structure and some sample data to illustrate what is currently being produced and what I'd like to produce. Sample table: CREATE TABLE Item (ID INT, ParentItemID INT NULL, ItemNo nvarchar(10), ItemName nvarchar(max), Budget decimal(18, 4), RevisedBudget decimal(18, 4)); Sample

PowerPivot Hierarchy Detection - Active Projects

廉价感情. 提交于 2020-01-16 20:04:45
问题 Building on Chris Campbell's Article regarding active projects, I'd like to add an extra dimension. My tables reference their own parent matter in a denormalised 2-layer hierarchy. After some calls to the RELATED() function, the main lookup table of projects can look like this: Cases ID | Client | ParentMatterName | MatterName | ClaimAmount | OpenDate | CloseDate 1 | Mr. Smith | ABC Ltd | ABC Ltd | $40,000 | 1 Jan 15 | 4 Aug 15 2 | Mr. Smith | ABC Ltd | John | $0 |20 Jan 15 | 7 Oct 15 3 | Mr.

Access top level resources outside of hierarchy

雨燕双飞 提交于 2020-01-15 07:34:07
问题 is there a way to synthesize an architecture in verilog such that a deeply nested endpoint can access some top level pins (from a .ucf) without expressly routing the pins through every module of the hierarchy. In my case i have a PCIe block with a deeply nested endpoint. AT the endpoint there have an address decoder that needs to provide some signal information from pins at the top level. I'd rather not modify every intervening module to carry the necessary wires. my web searches are

How can I determine permissions in a hierarchical organization?

醉酒当歌 提交于 2020-01-15 06:35:13
问题 I’m trying to create performant logic for determining permissions within a hierarchical organization. Employees are assigned to one or more units. Units are hierarchical with (theoretically) infinite depth (in reality it’s no more than 6 layers). For example, employee Jane may be the Supervisor of the Accounts Receivable unit (a child of the Accounting unit), and also Member of the Ethics Committee (a child of Committees , which is itself a child of Office of the CEO ). As the Supervisor of

SQL: Select SUM of all children records recursively

前提是你 提交于 2020-01-14 16:31:58
问题 I have a table that has a one to many relationship with itself. Each record can have n number of children from that same table. For example create table folder ID: Number 20 PK PARENT_ID: Number 20 FK references folder.ID SIZE: NUMBER 20 ... Given an ID, I want to select the SUM(SIZE) of all folder records recursively. The target database is MySql 5, but it would be nice if it was generic enough to work in Oracle and MS-SQL as well. I won't know how deep the tree is, could be 1 level, could