Why does Perch use a database?
There are a number of content management systems available that, like Perch, seek to solve the small CMS problem. Some of those use the fact they have no database as a feature. We sometimes get asked why Perch uses MySQL and this post is to explain some of the reasons behind that.
For a more in-depth technical explanation you can also see lead Perch developer Drew McLellan’s blog post on the subject, Why use a database with a small CMS?.
As Drew explains in his post one of our aims with Perch was to develop a high quality, small CMS. As a company our previous experience was in large-scale, custom sites. We know how to make your website fast and we don’t see why small or simpler sites should be developed with any less care and attention. We also wanted to make sure that your small site could grow using Perch as a framework, and that reasonably complex things could be achieved efficiently.
The problem with database-free systems is that they still have to store, retrieve and access data. At a very, very simple level you can just write to the HTML files that make-up your site. That’s fine and at runtime, very performant, as the visitor is just viewing an HTML document. However in practice you tend not to just want to edit and view basic pages using HTML. Enabling filtering and paging of information, reusing content around your site, enabling multiple editors to work on content without overwriting each other, saving drafts and previewing changes requires code to be written to support these features. Code to do things that a proper database, like MySQL, is optimized to do very well and a high level language like PHP, is not.
If you have never used a database before then getting to grips with MySQL might take you a few minutes. We’ve written some guides to help you do that, showing you how to get a local development environment up and running using XAMPP and how to move your database file and site from one place to another easily.
We have used our experience of creating fast, high performing websites in developing Perch and this is why Perch uses a database.