0

There is a taxonomy_term_data table and there is a taxonomy_term_hierarchy table. Why are there 2 tables, instead of them being combined?

taxonomy_term_hierachy strucutre

  • description of table: Stores the hierarchical relationship between
  • field: tid: 'Primary Key: the taxonomy_term_data.tid of the term'
  • field: parent: 'Primary Key: The taxonomy_term_data.tid of the term's parent. 0 indicates no parent.'

taxonomy_term_data structure:

  • description of table: Stores term information.
  • fields: vid, name, description, format, weight

Question motivation I am the maintainer of the draggableviews module. Currently module is using just 1 table. Going forward, the module's goal is to mimic taxonomy structure. Tried to search the web for an answer but could not find one.

4
  • 1
    A term can have multiple parents. This is easier represented in the taxonomy_term_hierachy strucutre Feb 12, 2015 at 16:22
  • @Reynolds, that would make sense, but tid is unqiue (primary key) and the parent field is an integer. Can you explain this?
    – iStryker
    Feb 12, 2015 at 16:28
  • @iStryker Not quite - it's a compound key across tid + parent, not just on tid
    – Clive
    Feb 12, 2015 at 16:29
  • My mistake, I did not see the compound key, thought it was just on tid.
    – iStryker
    Feb 12, 2015 at 16:35

1 Answer 1

3

taxonomy_term_data is the base table for the taxonomy entity type. It holds ID, property and bundle data for that entity type.

taxonomy_term_hierarchy holds the parent/child relationship between taxonomy terms (which of course can be multiple in nature).

You can't store the data for anything more than a one-to-one relationship in the same table, hence the split into two.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.