I'm trying to build a custom CMS tool (yes I know - ANOTHER CMS) where the users can create as many nested "nodes" as they want.
Example "Nodes": Restaurants, People, Shoes, Continents ... anything. Within each Node, there can be as many sub nodes as needed and so on and so forth.
While looking through Wordpress, Drupal... etc etc, I keep seeing tables like "taxonomy", and "terms".
This seems like a "normal" thing, but I can't wrap my head around how it should be done or how they're doing it. I assume these tables are related to the overall structure and table relationships, but... searches online come up shy of explaining what's actually going on or how best I would go about designing my database for this kind of structure.
Ideas I've had so far (that obviously aren't flushed out or I wouldn't be here asking):
1) Store known data types and bindModel():
Create tables like data_locations
and data_texts
that would have fields respective of their data. So - in the data_locations
table, I'd have city
, and longitude
, and address
. And in the data_texts table, I'd have title
, subtitle
, content
, author
.
Then, each time they created a new "Node", they could pick what kind of data-types it should have, and I would use bindModel()
to create the associations (I guess?).
This wouldn't be as flexible, but maybe easier to manage, and faster to run queries on...etc? Dunno.
2) Custom fields for each Node with single "data" table: Have a data
table, and a fields
table... each node would haveMany fields
- each with a type and maxLength...etc. Then, in the admin, I'd list those fields, and each chunk of data title
, shoe_size
...etc would have a row in the data
table that related to the node and to the field.
This one seems more like what I THINK the "taxonomy" thing is - but again, I really have no idea.