Why am I writing this?
I will be reading the code of a tag library. One of the first code reading steps is to understand what is involved before getting into the code. So, I am getting a quick overview of tags.
Tags are commonly used and easily understood.
reads the start of wikipedia entry
reads through the entire wikipedia entry slowly moving lips
Ahem, really? I thought this would be easy. I will look at hierarchical before non-hierarchical.
Hierarchical data is something with parents and children - a tree structure. The classic example of hierarchical data structure is storing employee management data. But, we will use a blog hierarchy.
|4||2||Ruby tips for Chef|
|5||3||Ruby 2.5 Rumours|
|6||3||Why I stopped using Elixir for Ruby|
Where the parent_id can create the following hierarchy.
If you are using hierarchical data to classify items you can only put the item in one place. Storing blog posts in a hierarchy means placing our Ruby posts and our Chef/Ruby posts in different folders. It is easier to find Ruby posts if they are kept together.
Non-hierarchical data means that the data does not have parent and child relationships. You can label anything with any label. Examples of non-hierarchical data are blog post tags and Gmail labels - without a limit on how we label Ruby posts.
The common way to implement tags is with three tables. If we wanted to tag posts then one posts table, one tags table and one table for the relationship between them - a posts to tags table. See figure 4. Wordpress ues the three table system.
Tags offer a way to classify data without molding it into a hierarchy. It is a popular solution for marking blogs and emails where labelling shouldn’t depend on where it is kept. The most common way of implementing tags is using a three table solutions.