This might appear strange but I've been trying to find a solution for any very long time and that i could not find any.

Let us suppose you've got a blog which blog has numerous publish records as with every other blog. Now each publish might have simple user comments. No like buttons or other resource that will require data management. The totally: Can One store user comments on one text file? Each publish is going to be connected to some text file store the comments. So, basically have n posts I'll have n text files.

I understand I'm able to perfectly do that, but I have not seen it elsewhere and we're not speaking about this. For me personally this appears much better than storing all coments from all posts in one mysql table but I'm not sure what causes it to be so bad that nobody has implemented it yet.

Storing comments in text files connected with corresponding publish? Lest find out if it is good idea.

  1. Okay adding new comments easy - write new text towards the file. But how about format of the data? CSV? Ok then you would need to parse it before rendering.

  2. Paging. For those who have lots of comments you might consider creating paging navigation for this. It is possible easily, sure. But you should open the file and browse all of the records to extract say 20.

  3. Approve your comments. Someone published new comment. You set it with pending status. So.. In admin panel you have to find individuals marked comments and process then accordingly - save or remove. Do you consider it's convinient with text files? Exactly the same if use made the decision to get rid of its comment themself.

  4. Reading through files for those who have many comments and several posts is going to be reduced the it might be just in case of database.

  5. Scalability. Eventually you deside to increase you comments functionality to allow one comment to reply to another. How does one get it done with text files? Or example from comments by nico: "In 6 several weeks time, when you will need to give a rating area towards the comments... you will have a large headache. Or, just operate a simple ALTER query".

Case for beggining. Someone will add something.

Well, you will find reasons why this is not done. I can not possibly title all of them, however the first stuff that spring to mind:

  1. Efficiency
  2. Versatility

Databases tend to be more effective and versatile than plain text files. You are able to index, search and assign secrets to individual comments and edit and remove any comments according to their key.

In addition, you'd obtain a huge pile of text files when the blog is very large. During itself that's no problem, should you all save them in a single directory, it may outgrow proportion and extremely boost the access time required to locate and open a particular text file.

Use table... That you can do a lot more and get it done faster with db.