CMS - writing your own. Database or file driven?

Associate
Joined
19 Jun 2003
Posts
1,680
Location
West Yorks, UK
Hi folks,
I have to write a basic CMS for a client next week, and have been wondering about the best way to store the data. The obvious way is to store it in MySQL, but I wondered about storing the data for each page in an XML file or even just as text/html. Obviously this would make searching harder (as a log XML file would need to be kept detailing what was in the others).

Just wondering if there are any benefits whatsoever in storing the data in flat files instead of a database really? (apart from you don't need a database to run it!)

Cheers,
Matt
 
Flat file implementation is probably simpler to start with, working easily with a small number of files. Database implementation comes into its own as a system grows in complexity and size.
 
If you're just managing very basic content, then even XML might be overkill. As you add more complex features - things like metadata (the date something was posted, categories or what-have-you) then you might want to look to XML; however, a database is much, much more flexible and will allow you to do more complex queries on your data.

Both will be roughly comparable in terms of speed to start off with, but I should imagine the flat-file based system will definitely be much less scaleable.
 
Yeah, I thought the XML would be ideal for small sites, but when I gave it more thought, I could only thing of two benefits for larger sites:
- No database required (hence cost saving)
- Ease of backup (ie., a bunch of files over FTP instead of files over FTP + MySQL dump)

I reckon i'll stick to the way everyone else does it - they must have done it for a reason I guess!

Matt
 
Back
Top Bottom