Article
Databased Websites from Scratch
Much has been written about building and maintaining data-driven Websites. These sites are typically seen to involve three tiers. The term 'three tier' refers to the metaphorical layers within a data driven Website:
Content, Program Logic, and Presentation
'Content' refers to all the text in the site - not the navigational links or images, but the raw textual information, such as news articles or product descriptions.
'Program logic' refers to the code that handles user requests for pages and displays them according to certain rules, such as: if the request comes from a Linux machine -- show this page.
'Presentation' refers to the code that handles the formatting of your content and displays it in an appropriate format, like HTML or XHTML.
My site, for example, is stored on a MySQL database. Page requests are handled by the PHP programming language and the presentation is handled by templates that contain HTML.
Benefits of a Data-Driven Solution
- Separating the content from the site's presentation allows you to display that content in different ways (such as through wireless devices), or to display browser-specific templates (see below).
- Templates allow you to change the appearance of an entire site in minutes. If you decide that a link needs to be added, or you make alterations to your copyright text, you can update one file (rather than hundreds) and affect the whole site instantly.
- Maintenance and editing can be performed by anyone who can fill out an online form -- you don't need editorial staff to know HTML or, in fact, any code at all . If you need to update product descriptions, for example, you can use a simple form that can be designed specifically for that purpose.
You may notice that I haven't made any mention of queries or ecommerce database functions here -- they're a little beyond the scope of this article.
Who Needs a Database?
If your site's content will be changed or added to more than once or twice a month, then you should consider using a database to store the content, and building an online administration program to manage it. The solution requires a little more work at the outset, but it will save you time and money in the long run.
If you intend to maintain a very small and fairly static site (such as an online business card) then stick to the traditional static approach -- this should be adequate for your needs.
If you want to build a data driven site, or just find a little more technical information on the topics we've touched upon, try these resources:
www.mysql.com
www.php.net
www.phpbuilder.com
www.devshed.com
Webmasterbase
Ok, so now you've decided that you need a dynamic, flexible site structure and that a databse is for you. So what next?
What You Need
If you're going to build a dynamic site then you're going to need a few things, namely:
- a Relational Database Management System (or RDBMS),
- a programming language that will help you manipulate your data and
- a template system to abstract presentation from code.
Which RDBMS?
For most of today's small to medium-sized sites, MySQL is the answer. Why? Because:
- It's very powerful
- It's very fast
- It's very simple
- It has an almost fanatical online community from which you can draw knowledge and support
- It's free!
Which programming language?
On the basis that we've chosen MySQL as our database the answer here is a forgone conclusion: PHP. Although there are many other ways to interact with MySQL, the combination of PHP and MySQL is very well documented and thousands of sites rely on this excellent marriage of technologies to efficiently manage their data. Some of PHP's benefits include:
- Its simplicity
- Its power
- Its community support
- It's free!
Which template system?
There are two schools of thought as to which template system is best: PHPLib or FastTemplate. Experienced programmers are divided and both factions are passionate in their debate. I've chosen PHPLib because unlike FastTemplate, which was ported from an original Perl script, PHPLib has been exclusively designed for PHP from the ground up.
So our decisions have been made: PHP, MySQL and PHPLib templates.
Nick Wilson runs