Web Perspective by Eric Hammond

A free database can boost your site

Check out MySQL before you invest in Oracle or Microsoft

Summary
Although a relational database can add power and security to your Web applications, its complexity can also drain your wallet and cost you time. You don't have to go with a big, expensive database like Oracle or Microsoft SQL, though -- it's possible that MySQL, a free database you can download off the Web, might give you everything you need. (750 words)
Netscape Enterprise Developer

February  1998

Table of Contents
Subscribe, it's free!
Search Netscape Enterprise Developer

If you've decided your Web site or intranet needs the performance, reliability, and security of a relational database management system (RDBMS), you might be intimidated by the prospect of choosing between the available options. RDBMSs tend to be expensive, complex, and resource intensive -- but they don't have to be. It took some searching, but I found a couple of inexpensive (in some cases free) RDBMS options for Web developers that can help you keep your database development simple and cost-effective.

The benefits of using a database as an integral piece of your Web application are clear. An RDBMS controls access to the records stored in it, meaning you won't have to do low-level coding to make sure two users don't simultaneously update the same record. In addition, an RDBMS can manage security, ensuring that users only have access to the information they need. Finally, an RDBMS can provide performance enhancements by indexing data and optimizing query performance. An RDBMS can also improve performance by allowing you to build a multitier architecture, performing database processing on a server that is independent of your actual Web server.

By the same token, if you don't need any of these features, you don't need an RDBMS. If your applications don't need such power and management capability, follow the keep-it-simple rule and avoid adding unnecessary pieces to your system.

Database options
When most corporate types think databases these days, they probably think Oracle. Oracle is far and away the industry leader in terms of market share and, perhaps, mind share. But an investment in an Oracle database system isn't a trivial matter. It costs a lot of money up front and costs still more money to support. The time and money constraints placed on many Web development projects tend to make it difficult, if not impossible, to implement Oracle as your RDBMS solution.

As another option, Microsoft's SQL Server is rapidly gaining popularity as Windows NT's share of the server market grows. While it might be easier to implement SQL Server instead of an Oracle system, it still isn't cheap -- and it requires you to run an NT box as the database platform, an extra hassle if you don't already have one set up.

A better choice?
Enter MySQL, a full-featured SQL database that you can download off the Web. MySQL is free unless you want to bundle it with an application that you distribute for money. In that case, or in case you just like the product and want to show your appreciation, the license fees start at about $200. Support -- critical in a corporate environment -- is available starting at $200 per year.

You can download MySQL's binaries and source code for any number of platforms from its Web site. I downloaded the RedHat Linux version and installed it on my VA Research dual 333MHz Pentium II server running RedHat Linux 2.0.

The RedHat version came as a series of RPM files that installed easily and quickly. The product includes a GUI-based tutorial that walks you through the basics of using MySQL. Though I had some trouble getting the tutorial to work properly, I was able to run its examples from the command line with no difficulty.

The download includes everything you need to set up the Perl database integrator (DBI) to work with MySQL. Because I've used DBI before, I had little trouble working with it in my Perl scripts; first-time users may, however, find its quirky documentation a little frustrating. There's some documentation online, but the best way to figure it out is to look at the examples in the mysql.pm DBI module loaded in the installation process.

As an example of how MySQL works, here's a short snippet of Perl that extracts one row of data from a table called "demo" and prints out the results:


#!/usr/bin/perl

use Mysql;

$dbh = Mysql->connect(localhost, tutor);

$sth  = $dbh->query(select * from demo);

@arr = $sth->fetchrow;

print $arr[0] $arr[1] $arr[2] \n;

Inserting records uses a similar process. Wrapping the constructs needed for HTML around this code makes building database applications fairly simple. One nice feature of DBI is the fact that if you change database platforms, you simply change the DBI module used to connect. Most, if not all, of your code will work with the new RDBMS with no modification.

Depending on your platform, many other free or low-cost RDBMS solutions are available, including Ingres, mSQL, and Postgress. Download one today and see how it meets your database needs!

Resources

About the author
Eric Hammond is a technology analyst in InfoWorld's Test Center. Previously he was a computer scientist at the Department of Energy. Reach Yun at eric.hammond@ne-dev.com.

What did you think of this article?
-Very worth reading
-Worth reading
-Not worth reading
-Too long
-Just right
-Too short
-Too technical
-Just right
-Not technical enough
    

Table of Contents Subscribe, it's free! Search Netscape Enterprise Developer

[(c) Copyright 1998 ITworld.com Inc., an IDG Communications company]

If you have problems with this magazine, contact webmaster@ne-dev.com
URL: http://www.ne-dev.com/ned-02-1998/ned-02-develop.html
Last modified: Saturday, November 20, 1999 HYIP Monitor