mysql organize hierarchical data – Ask Different

I have a table similar to the structure mentioned below but with 5 levels.

table name: location
locationID INT UNSIGNED NOT NULL AUTO_INCREMENT,
parentID INT UNSIGNED NOT NULL,
name CHAR(255)

I am storing Country, State, District, City, Area in this table and each one references the category to which it belongs.

In the front end I would like to display in a dropdown in the following format ordered alphabetically

Country
Country->State
Country->State->District
Country->State->District->City
Country->State->District->City->Area
Country (This would be the second country) and so on

Depending upon the selection the id of that item would be returned to store.

How do I create a view in mysql to represent the above which can be queried in PHP and data displayed in front end.

The view would have the columns
Id : Id of the last level
Tree: The tree structure outlined above.

Regards
Arjun

8 – Get hierarchical content

I have a content type Article and have two vocabularies Book and Chapter.
The two vocabularies are fields of entity reference in Article.
There is no direct relation between the Book and Chapter.

Now I need to get the Articles, based on Book then group them under chapter.
Can I do this in Views module?

The Structure will be like below:
Book - Chapter - Article

Please note, I can’t use Books Module.

grid – If it’s possible to combine plain and hierarchical view together?

I’m facing the issue of data representation. On the same page, it’s possible to view both plain and tree structure. It’s ok (tbh no, but we can live with it for a while), but when it comes to new object creation it feels like a duplication as it appears in two places.

  1. As nested object
  2. As an object in the list

Question:
Any idea how to solve it? How to get rid of the feeling of duplicated object? Keeping the plain and tree structure on the same page?

Thanks.

short gif

hierarchy – Display suggestions for hierarchical checkbox lists (trees)

I’m working on a web-app for a document management system where employees upload documents and associate them with metadata. In many cases, we are able to predict certain metadata properties and we would like to suggest those predictions to the user.

For normal text-input fields, this is not a problem as we simply use auto-suggest. However, a lot of times, we do not use text-input fields but hierarchical checkbox lists (see image below).

We are unable to find a satisfactory method to display suggestions in these cases.

Assume the following fictional scenario: We are a manufacturing company. At the end of each day, every employee uploads a short work-report. After uploading the document, the employees have to select the machine(s) they were working with:

enter image description here

Now comes the challenge: From the working plan we actually know that on 26.05.2020, James Smith is supposed to work with the CNC Machine. However, we also know that he was working with another machine in Manufacturing Plant XX for the last days.

We would like to suggest both machines to him while still giving him the possibility to pick every other machine.

  • Solution 1: Auto-select button

    Add a button that automatically selects the n most likely nodes when clicked.

    • Con’s:
      • Not really a suggestion
      • The value for n is not clear
      • Users have to de-select wrong suggestions
  • Solution 2: Suggestion dialog

    Add a button that opens another dialog from which the user can pick suggested nodes.

    • Pro’s:
      • Gives the users the ability to pick the right suggestions
    • Con’s:
      • Opens a dialog on top of a dialog
      • Distracts the workflow
  • Solution 3: Highlight the suggested nodes

    Highlight the suggested nodes and expand their parent-nodes to make them visible.

    • Pro’s:
      • Relatively subtle
      • Does not distract the users too much
    • Con’s:
      • Could be unclear for the users
      • Does not reduce the number of clicks for the users
  • Solution 4: Auto-suggest in the filter

    Add auto-suggest to the filter text-input.

    • Pro’s:
      • Does not distract the user
    • Con’s:
      • Only available if the user uses the filter
      • Requires the most interaction

Does anybody know a good solution for problems like this?

php – Hierarchical taxonomy list with transformated links

I have two functions displaying a term list of the selected taxonomy:

First function:

$terms = get_the_terms(get_the_ID(), 'MY_TAXONOMY');
if (!is_wp_error($terms) && !empty($terms)) {
    foreach ($terms AS $term) {
        $name = $term->name;
        $link = add_query_arg('fwp_typ', FWP()->helper->safe_value($term->slug), 'https://www.MYWEBSITE.com/');
        echo "<a href='$link'>$name</a><br />";
    }
}       

Second function:

    global $post;
    $taxonomy = 'MY_TAXONOMY';
    $terms = wp_get_post_terms( $post->ID, $taxonomy, array( "fields" => "ids" ) );
    if( $terms ) {
        echo '<?ul>';
        $terms = trim( implode( ',', (array) $terms ), ' ,' );
        wp_list_categories( 'title_li=&taxonomy=' . $taxonomy . '&include=' . $terms );
        echo '<?/ul>';
    }

The first one ignores the hierarchy, but transforms the links as I need, i.e. so that they lead to queries of the WP’s Facet Plugin. I understand that this line is key here:

$link = add_query_arg('fwp_typ', FWP()->helper->safe_value($term->slug), 'https://www.MYWEBSITE.com/');

The second one includes the hierarchy, but the links don’t lead where I would like. How do I make this second function transform links like the first one?

hierarchy: a hierarchical process

Let's say we have a system where you can modulate a process and track its status and the tasks currently running.
1. The process has stages of naming higher level groups
2. Each stage can contain groups (no more than two nested groups)
3. Each stage or group can contain one or more tasks that are executed sequentially or in parallel

What view would you use to create such a process: dashboard, left pane tree + main grid, tree grid, or other?

gnome – How to get hierarchical menus with "launchers" for all applications in Ubuntu 20

I used to have a hierarchical menu in the upper left, which allows me to start applications, similar to the old Windows start menu.
The good thing about this is that you can organize the launchers, instead of having everyone on the same level, like in the Dock.
In Unity, for example, Drawers intended to allow a similar ability.

How can I get this menu in Ubuntu 20?

I know I can just search for an app in Activities.
The menu I'm referring to is not a replacement for that, but complementary.
In this menu, I can explore what is available, in an organized way.

sql server – Retrieve hierarchical data

I have the following tables:

Teachers:

+------+--------+
|  id  | deptId |
+------+--------+
|  1   |    2   |
+------+--------+
|  2   |    1   |
+------+--------+

Department:

+------+-----------+
|  id  | contactId |
+------+-----------+
|  1   |     2     |
+------+-----------+
|  2   |     6     |
+------+-----------+

Contact:

+----+--------------------+
| id | nonImportantColumn |
+----+--------------------+
| 2  |   street street    |
+----+--------------------+
| 4  |   street2street    |
+----+--------------------+

SchoolBranch:

+----+-----------+----------------+
| id | contactId | parentBranchId |
+----+-----------+----------------+
| 3  |    2      |     null       |
+----+-----------+----------------+
| 4  |    5      |     3          |
+----+-----------+----------------+
| 5  |    7      |     null       |
+----+-----------+----------------+
| 6  |    2      |     3          |
+----+-----------+----------------+

Given a master id, let's say 2, I am trying to get the result set format shown below but I don't know how to start. I am not an expert.

+----------+-----------+----------------+--------------------+
| branchId | contactId | parentBranchId | nonImportantColumn |
+----------+-----------+----------------+--------------------+
|    3     |     2     |      null      |  some street adr   |
+----------+-----------+----------------+--------------------+
|    4     |     5     |        3       |  some street adr   |
+----------+-----------+----------------+--------------------+
|    6     |     2     |        3       |  some street adr   |
+----------+-----------+----------------+--------------------+

The result contains the data for the id. From branch 4 and 6 because these branches are secondary branches of 3 (which is linked to our input master ID: 2)

I am using SQL Server v 18, in case it helps.

lists – 3-level hierarchical data presentation

I am updating the user interface of an existing desktop website. I need to display 3 levels of hierarchical data. There are categories that contain parents (with several properties) that in turn contain children (also with several properties).

I am not interested in this presentation, but I cannot think of anything better. You could put each level on a separate page and use a breadcrumb like navigation, but there is a bit of movement between levels (parents can move to different categories and kids can move to different parents).

Any ideas?

Health

categories – WordPress speed: hierarchical versus non-hierarchical taxonomies?

I am creating a site that will eventually host thousands of posts, all of the same "Artwork" custom post type.

Each blog post has multiple assigned custom taxonomy terms, e.g. "Artist", "Project", "Artdirector", "Format" and more.

I have read that too many taxonomies and / or terms can slow down the page. Therefore, I am not sure if I should build a structure with many non-hierarchical taxonomies, or with only one or two hierarchical taxonomies but more terms and secondary terms.

Many taxonomies, mostly non-hierarchical:

 • Artist Taxonomy (non-hierarchical): 1000s of terms (1 per post)
 • Formats Taxonomy (hierarchical):
   – Formats Terms: 4 terms (1 per post)
     –Format Child-Terms: 15 terms (1 per post)
 • Projects Taxonomy (non-hierarchical): 100s of terms (1 per post)
 • Artdirectors Taxonomy (non-hierarchical) 100s of terms (1 per post)
 • Genres Taxonomy (non-hierarchical): 20 terms (1-3 per post)
 • Collections Taxonomy (hierarchical):
   – Collections Terms: 50 terms (0-1 per post)
     - Collection Child-Terms: 100-200 terms (0-5 per post)
 • Publisher Taxonomy (non-hierarchical): 30-40 terms (0-1 per post)

vs.

Fewer, but hierarchical, taxonomies:

 • Artist Taxonomy (non-hierarchical): 1000s of terms (1 per post)
 • Meta/Collections Taxonomy (hierarchical):
   – Formats Terms: 4 terms (1 per post)
     –Format Child-Terms: 15 terms (1 per post)
   – Projects Term:
     – Project Child-Terms: 100s of child-terms (1 per post)
   – Genres Term:
     – Genre Child-Terms: 20 child-terms (1-3 per post)
   – Artdirectors Term:
     – Artdirector Child-Terms: 100s of child-terms (1 per post)
   – Collections Term:
     – Collection Child-Terms: 50 terms (0-1 per post)
       – Collection Grandchild: 100-200 grandchild-terms (0-5 per post)
    – Publisher Term:
       – Publisher Child-Terms: 30-40 child-terms (0-2 per post)

Are there any advantages / disadvantages to either of these two structures when it comes to website speed? My concern is that it could become slow once thousands of posts are on the page.