Reputation: 1
So, I was going to make a CMS and I just wanted some options.
The idea is simple but no one else seems to do be doing it so there has to be something wrong with the idea right?
Basically, I will have a table called 'fields'. This table will contain individual data fields. I would then have a second table called data_node which is a grouping of fields to create a data object.
So, a data_node would be a blog post. This data_node would have 4 fields. Title, content, created, published.
The fields table would have 4 entries, the data_node table would have 1 entry
At the PHP level, you would then have modules which would access the data nodes.
Is there a downside to this? There would be a lot of work for one table to do but for medium websites this wouldn't be a problem right?
Upvotes: 0
Views: 1712
Reputation: 9335
I had developed a system using this architecture some years ago for a scientific project funded by the EU. It was a nice experiment.
The downsides, from my experience:
Upvotes: 0
Reputation: 185643
What you have defined is essentially an EAV structure. EAV is typically implemented with three tables, one defining the entities (posts, in your case), one defining the attributes (Title, Content, Created, Published, etc.), and one that provides a single value for a given entity and given attribute.
As you've obviously deduced, EAV structures allow for very flexible storage of homogeneous data, as you're abstracting away everything that defines what something "is" into another layer of data. The upside is the flexibility, but the downsides are many:
EAV structures have their place, though that's usually when developing systems where individual end-users want to define custom attributes for an entity without having to have the application or the database changed. Unless you need this flexibility, the cost greater than the benefit.
Upvotes: 2