DEV Community

Cover image for Relational tags
Owen Gallagher
Owen Gallagher

Posted on

Relational tags

Why not?

Let's combine the best of two disparate organizational systems: tree hierarchy, and tags.

tree hierarchy graph

  • tree
    • Very intuitive for grouping, and maintaining a spatial metaphor (ex. file system with folders, geolocation with quadrants).
    • Memorable relationships between entities, permitting easy search by incrementing specificity (users > myself > images > cats > fat_cat.png).
  • tags
    • More improvised/ad hoc approach, where organization evolves organically without knowing what is more or less specific.
    • Less rigid classification than the hierarchy tree, with loose relationships.

Relational tags would have the flexibility of tags, with an additional layer of association by defining relationships between tags. I wonder if something like this concept is used in applications like knowledge graphs and mapping natural languages.

For example, I’ll organize the following entities according to the three systems. Note there are certainly many ways to do so:

apple, banana, cat, dandelion, grass, 
mouse, school bus, strawberry, Rudolph
Enter fullscreen mode Exit fullscreen mode

Tree example

- alive
    - plant
        - yellow
            - banana
            - dandelion
        - red
            - apple
            - strawberry
        - green
            - grass
    - animal
        - cat
        - mouse
        - Rudolph
- inanimate
    - school bus
Enter fullscreen mode Exit fullscreen mode

Note, for example, that I didn’t put school bus in yellow because it’s only allowed to have one parent node. A filesystem typically gets around this with aliases/symbolic links/shortcuts/etc.

Tags example

- apple - fruit, plant, alive, red, sweet
- banana - fruit, plant, alive, yellow, sweet
- cat - animal, alive, mammal, carnivore
- dandelion - plant, alive, yellow, flower, bitter
- grass - plant, alive, green, bitter
- mouse - animal, alive, mammal, herbivore
- school bus - inanimate, yellow
- strawberry - red, plant, red, sweet, alive
- Rudolph - alive, animal, red, fiction, herbivore, mammal
Enter fullscreen mode Exit fullscreen mode

Note here that adding new entities to this system becomes tedious, and entity-tag assignments are easily forgotten.

Relational tags example

Tag relationships

These could be directed or not; I’m not sure which is more useful.

alive --> animal, plant, animate
inanimate
color --> red, yellow, green
animal --> mammal, carnivore, herbivore
plant --> fruit, vegetable, flower
fruit --> sweet
flavor --> sweet, bitter
existence --> reality, fiction
Enter fullscreen mode Exit fullscreen mode

Entity-tag assignments

Apple - plant, fruit, red
Banana - fruit, yellow
Cat - mammal, carnivore
Dandelion - flower
Grass - plant
Mouse - mammal
School bus - yellow, inanimate
Strawberry - fruit, red
Rudolph - animal, fictional
Enter fullscreen mode Exit fullscreen mode

Hooray! Now, an entity can belong to any number of tags, and tags have relationships with each other, so I don’t need to remember to add alive and plant to all of my fruit entities.

If I change my mind about the tag relationships, I can easily redefine them.

If I want to search for entities, I can search by tags and the tag relationships will pull in entities assigned to related tags as well.

P.S.

This is more a discussion/opinion thread than anything else.

Is this a new concept, or a new application for an existing concept, or neither? The most immediate application I can think of from a user perspective is a computer’s file system, where the strict tree structure can become cumbersome.

If you’ve seen this implemented in an existing operating system or software framework I’d much like to know about it.

Top comments (1)

Collapse
 
owengall profile image
Owen Gallagher

I've explored implementation at github/ogallagher/relational_tags.