Reputation: 83
I'm building a custom CMS system that will store articles.
What is the correct way to store the article in the db? Given that an article may consist of a single paragraph or any number of paragraphs and may contain images it doesn't seem practical to store each paragraph in a distinct field of the db.
I have looked at how Wordpress stores posts and it seems to lump the raw html in a single field `post_content'. Is this an accepted method? The disadvantage I see with this method is that for each article any html mark-up is also stored. If I only stored the raw text then the dynamic page which displsys the article would only contain the html mark-up just once. But then how to derentiate between paragrpahs and images?
Any thoughts?
Thank you.
Upvotes: 2
Views: 673
Reputation: 3703
The field of choice would be a BLOB type (for example TEXT).
What data to store is however a different matter, and really depends on your implementation. I've worked on similar systems and have in the past stored data as:
If you're looking for some kind of analytic data from the images which are linked, I would suggest storing the image URI in another table and linking to a primary key ID of the URL. This means that you can check and not duplicate image URL's. Image URI could equally be an ID if you upload and store the images within your domain.
Upvotes: 3