Database-Driven Sites
What are Database-Driven Sites?
A database driven approach to web development simply refers to the use of a database for storing a website's content. It involves the separation of a site's content (words and pictures) from its design (the look, feel, and navigation). The design is most typically stored in template files. When a site visitor requests a page by clicking a link, a template draws the appropriate information from the database before it displays the result as an HTML.
By contrast, a static website is comprised of a series of HTML files. These files are self-contained documents that appear the same to all users, regardless of where, how, when, or why they are viewing the document. A single static file holds all of the data for a particular page (text, images, navigational structure, etc.) and the design and content are intertwined. When a site visitor requests a page, the HTML file is passed from the server to the visitor's browser. On a static site, visitors are simply viewing documents over the internet, in much the same way they might open files on their own hard drives.
To illustrate the difference between a static and a database driven site, consider a site that contains 25 product pages. Using a static web development model, a programmer would need to create 25 separate HTML pages with the same basic navigational structure, each containing an individual product's specs and information. To add a new product to the site, the programmer would need to create a new copy of the product page file and insert the new product's information into the appropriate places within the file. To make a change to the structure of all 25 product pages, the programmer would need to adjust each of the 25 HTML pages by hand.
Using a database driven approach, the programmer would build a product table in the website's database. This table would contain a series of columns with pertinent information about the product line. For instance, the table might have the following columns: "product identification number," "product name," "product size," "price," "availability," "description," and "image." The programmer would then create a template file to use the information from the product table. This template file would contain the basic structure of a product page, identifying elements like the navigation system, where a product image is placed, where the description and other information goes on the page, and how all the data is to be formatted. When a user visits a particular product page, the template grabs the data associated with that product's identification number from the database, plugs the data into the template and presents the user with a complete product page immediately.
Advantages of Using a Database-Driven Site
- Ability to manage your website by simply adding data to the database and to dynamically update your website.
- Ability to easily implement features, such as sorting in ascending/descending order alphabetically, by date, or by popularity for items such as downloads, articles, or tutorials.
- Ability to add searchability to your website and let users find exactly what they need.
- Ability to allow others (staff) to manage your website through the database and specify permissions for users.
- Allow the community to submit articles/content to your website and dynamically update your website.
- Less work, self-run website that enables easy management and consistency.