# Hierarchical Data
Hierarchical data is information organized in a tree-like structure where each item (except the root) has exactly one parent and zero or more children. This parent-child relationship creates nested levels from general to specific. Common examples include file systems (folders containing files and subfolders), organizational charts (CEO → departments → teams), taxonomies (kingdom → phylum → class), and XML/JSON documents.
Hierarchical structures are intuitive because they mirror how humans naturally categorize information—from broad categories to specific items. However, they have limitations: real-world relationships often don't fit neatly into strict hierarchies (an employee might report to multiple managers), and deep hierarchies can become unwieldy. Alternatives include network/graph structures (multiple parents allowed) and flat tag-based systems.
## Structure
```
Root
│
┌────────────┼────────────┐
│ │ │
Child A Child B Child C
│ │
┌───┴───┐ ┌───┴───┐
│ │ │ │
Leaf 1 Leaf 2 Leaf 3 Leaf 4
```
## Terminology
| Term | Description |
|------|-------------|
| **Root** | Top-level node with no parent |
| **Parent** | Node with children below it |
| **Child** | Node with a parent above it |
| **Leaf** | Node with no children |
| **Sibling** | Nodes sharing the same parent |
| **Depth** | Distance from root (levels) |
| **Path** | Route from root to a node |
| **Subtree** | A node and all its descendants |
## Examples
| Domain | Example |
|--------|---------|
| **File Systems** | `/home/user/documents/report.pdf` |
| **Organizations** | CEO → VP → Director → Manager |
| **Biology** | Kingdom → Phylum → Class → Order → Family |
| **Geography** | Continent → Country → State → City |
| **Web** | DOM tree, site navigation |
| **Data Formats** | XML, JSON, YAML nested structures |
## Hierarchical Data Formats
| Format | Example |
|--------|---------|
| **JSON** | `{"parent": {"child": "value"}}` |
| **XML** | `<parent><child>value</child></parent>` |
| **YAML** | Indentation-based nesting |
| **File path** | `/folder/subfolder/file` |
## Visualization Methods
| Method | Best For |
|--------|----------|
| **Tree diagram** | Showing relationships, org charts |
| **[[Treemap]]** | Proportional size of leaves |
| **Indented list** | Expandable/collapsible navigation |
| **Sunburst** | Circular hierarchical view |
| **Icicle chart** | Linear hierarchical proportion |
| **Nested circles** | Containment relationships |
## Hierarchies vs Networks
| Aspect | Hierarchy | Network/Graph |
|--------|-----------|---------------|
| Parents | Exactly one | Multiple allowed |
| Structure | Tree | Graph |
| Navigation | Single path to root | Multiple paths |
| Example | File system | Social network |
| Complexity | Simpler | More flexible |
## Limitations
- **Single classification**: Items can only belong to one branch
- **Rigid structure**: Doesn't reflect multi-faceted relationships
- **Deep nesting**: Can become hard to navigate
- **Maintenance**: Reorganization can be complex
## Alternatives
- **Tags/Labels**: Flat, multi-dimensional classification
- **Faceted classification**: Multiple independent hierarchies
- **Graph databases**: Network relationships
- **Polyhierarchy**: Items in multiple locations
## References
- https://en.wikipedia.org/wiki/Hierarchical_database_model
- https://en.wikipedia.org/wiki/Tree_(data_structure)
## Related
- [[Treemap]]
- [[Information Architecture (IA)]]
- [[JavaScript Object Notation (JSON)]]
- [[Yelling at my laptop (YAML)]]