Computer Science Canada

What to use to store blog posts?

Author:  michaelp [ Thu Jul 01, 2010 8:43 pm ]
Post subject:  What to use to store blog posts?

I have a website, and on that website, I have a small blog section and a news section. I plan to use the same system to store the blog and news posts.
My original plan was to store all of the posts in a MySQL database. The one post that is there is stored in a MySQL database.
However, I just looked at XML, and storing an XML file with all of the posts in them seems plausible as well.
Does anyone know if there any specific benefits to either way of doing it? Does anyone have experience with this?

Author:  DtY [ Thu Jul 01, 2010 9:29 pm ]
Post subject:  RE:What to use to store blog posts?

First of all, don't confuse XML with a database. Some programs (*cough*iTunes) use XML as a database, and it's horrible.

If you decide to use XML, keep in mind that you'll pretty much have to edit the XML file by hand to add posts, whereas with MySQL, you could easily create a web form to add a new post.

Another problem with using XML to do this is that you have to load the whole document every time, which isn't an issue when you want to load the whole document, but if you wanted to, say, load a single post, with XML you would still have to load the whole document, whereas an SQL database would make this very easy and fast to do.

If you decide later to add comments, it would be a pain with XML, but with MySQL, all you have to do is;

SQL:
CREATE TABLE comments (id INT PRIMARY KEY AUTO_INCREMENT, author VARCHAR, content TEXT, blog_id INT)


And retrieving a list of comments for a blog post and adding more would be trivial.

There are blogging systems that don't use a relational database to store posts (well, I know of one, but it uses YAML instead of XML), but each post is stored in a separate document, that is created by hand.

So, it would be possible to do it with XML, but I would advise against it.

Author:  Tony [ Thu Jul 01, 2010 10:55 pm ]
Post subject:  RE:What to use to store blog posts?

XML is a way to organize information in a file. A database _could_ use XML as its underlying storage format, but unless that data needs to be trivially portable and/or editable by hand, there would typically be better approaches.

TL;DR MySQL is a Dabase Management System and gives you the tools to store and manage data. XML is just a data markup format, you would have to write the software tools to use this file yourself.

Author:  rdrake [ Thu Jul 01, 2010 11:31 pm ]
Post subject:  Re: What to use to store blog posts?

XML is a bad idea, forget about it. I mean, you can do it, but just don't.

Small site? Little posts/users? Don't forget about your other simpler database options like SQLite.

Hell, you can keep all your posts as text files formatted with Markdown or a similar markup language ala Marley. Marley even has it so you can create a Git repository and update your articles through that.

TL;DR: Read Tony's TL;DR above.

Author:  michaelp [ Fri Jul 02, 2010 5:22 pm ]
Post subject:  RE:What to use to store blog posts?

Sounds like I should keep using MySQL database then. The free host I use (000webhost.com) comes with MySQL, so it makes it easy.
Thanks.

Author:  Brightguy [ Fri Jul 02, 2010 6:13 pm ]
Post subject:  Re: What to use to store blog posts?

MySQL does probably allow you more freedom, but that's not always a good thing. I bet it's more common to end up doing a hack job using MySQL. For example, I haven't seen the source of this website, but judging by the HTML source I can only imagine the kind of jury-rigged source behind it. Shifty Using something like XSLT to transform your XML data into XHTML would probably at least be cleaner, if nothing else1. And no, you wouldn't have to edit the XML by hand to add a new post.

By the way, I validated your site against the XHTML 1.1 DTD and there is one error: there is no attribute lang in the relevant XHTML 1.1 specification. If the W3 validator passes your site it's incorrect.

Also, you should not send XHTML 1.1 documents as text/html. Even if it is allowed in particular circumstances, it's asethetically repellent: It's like painstakingly putting together a 5-star dinner and then immediately before serving it you put the meals in a blender and serve the resulting soup. Of course... it just so happens that one important patron is a senile old man named Internet Explorer who can't digest anything but tag soup.

In short, maybe you mean to use XHTML 1.0, not XHTML 1.1.

_____
1 And since XSLT and XHTML are applications of XML, you would be using XML to transform XML into XML, wheee!

Author:  Mikleena [ Wed Nov 24, 2010 7:09 am ]
Post subject:  Re: What to use to store blog posts?

Hi all, I also want to know about this, I also new for this. Please share your opinion as soon as possible.
Thanks for sharing.


: