Jump to content

Storing An Article


computermax2328

Recommended Posts

Hello Everyone,

 

I was wondering what the best practice would be for storing a blog article. I am currently building a blog and I was just wondering what technique everyone used. All I did was simple store it in a MYSQL Database as a long text. I was also thinking about storing it in a folder somewhere as well.

 

What do you think??

Link to comment
Share on other sites

I was also thinking about storing it in a folder somewhere as well.

 

I see nothing to be gained from storing the same content in the DB as well as in a flat file. It would take more overhead and create greater opportunity for the content to get out of sync between the two. Besides, if you can't rely upon whatever storage method you are using then you are using the wrong method.

 

As to what field type you use is dependent upon how much and what type of content you would be storing. Longtext would work (supporting up to 4,294,967,295 characters), but that might be overkill to me. I would think that a medium text (supporting up to 16,777,215) characters would more than suffice. That would be more than 4,000 pages of content on a normal double-spaced printed page! By comparison a "normal" text/blob field (65,535 characters) would provide room for up to 16 pages of content on a double-spaced printed page.

 

There are performance/storage costs to using larger fields than needed. But, to be honest, I'm not sure of all the ramifications. So, I would use the smallest field type that is larger than anything you would ever expect to have to save.

Link to comment
Share on other sites

The only reason I want to store it as a file on the database is to have a secondary backup. It can't hurt.

 

You'd probably be better off using that disk space to store a .sql file backup of the whole database. If anything happens to the database you can restore it from one of the backup sql files and be on your way again rather than having to try and import a bunch of text or html files you wrote out.

 

Link to comment
Share on other sites

I concur with kicken.

 

The only reason I want to store it as a file on the database is to have a secondary backup. It can't hurt.

 

Yes, it can hurt. You likely have a process to allow users to edit blogs. You may end up with multiple methods of editing a blog. You would then have to ensure each method is updating both the database and the flat file consistently. Plus, you would be using resources that would be better utilized elsewhere. Plus, editing/updating flat files is much more problematic than database records and could lead to errors. I think you wanting to do this comes from a lack of having much experience with databases. I know that in my early days of programming I preferred to store some data in a file rather than in a DB because I just "didn't get it".

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.