PLEASE note: These pages are here solely for historic purposes. New articles have not been written since 2001; many links in the index are broken; and most ahref.com email addresses will now bounce. Try visiting ep Productions, Incorporated, the web programming and development company behind this site.

Tip: Want to know when we post new content? Subscribe to our newsletter.

web index ahref.com: a community space for web developers------ -----
IndexToolsCareersTalk
ahref.com > Guides > Technology

Technology Guide

Web Databases, Continued

Connecting to the Database

The final thing to decide is what tools you will use to connect to your database. There are a number of applications which claim to let you connect your database to the Web without programming. However, they generally don't let you customize your applications to the degree other solutions do—or if they do, they make you jump through some serious hoops.

In most cases, you should use the same CGI programming language or server-side scripting (SSS) system to connect to your database as you do to provide other interactive services on your web site. (An SSS system lets you place programming commands inside your HTML files, while CGI programs generally require all information to reside in separate programs, rather than inside HTML pages.) Almost all of the popular web programming languages and SSS systems can communicate with the databases we've covered so far.

On Windows NT, Active Server Pages (ASP) and Cold Fusion (an advanced, proprietary scripting system) are two good server-side scripting solutions (see our guide to ASP Basics for more information). PHP (an open-source scripting system) and EmbPerl (a scripting system that lets you embed Perl commands and programs in HTML files) work on both Unix machines and Windows NT systems. You can use Perl, C, C++, and Java on either platform to write CGIs.

On Anchor, we use PHP because it runs quickly and is easy to implement. If I were redoing the technical aspects of Anchor now, I would consider using EmbPerl instead. Because it was designed to be easy to learn and implement, PHP does not have all the capabilities of a more mature, more powerful language like Perl. We don't need anything that PHP can't do yet, but when we do, we may have to turn to Perl scripts for added functionality.

What is an API? What is ODBC? DBI?
There are a lot of buzzwords and acronyms in the world of web databases. Many we've already covered earlier in this series. A few extras you might want to know about are API, ODBC, and DBI.

API stands for Application Programming Interface. Database creators (and web server creators) write APIs to provide standardized ways for other programmers to interface with the database systems. Essentially, the API defines what commands (with what input) a program can send to a server. It also defines what sort of output the program should expect to receive back.

ODBC stands for Open Database Connectivity. It is an API that was initially developed by Microsoft to standardize how programs talk to databases, and is mostly used on Windows NT-based databases. It's useful because it allows you to write programs that don't have to be database-specific. Rather than writing your program to interface with Microsoft SQL Server's API, then rewriting the program if you move the data to an Oracle database, you can just write the program to connect to an ODBC source. Then if you move the database from one system to another, you just need to change that ODBC source (a relatively simple task).

DBI is similar to ODBC but is specific to Perl. DBI modules are available for connecting to Oracle, MySQL, MiniSQL, Sybase, ODBC, and other database servers. (If you used DBI to connect to an ODBC source, you'd have two layers of APIs between your program and your database.) By writing a Perl program using the DBI module, you can increase the portability of your code and cut down on future work. Changing from one data source to another using DBI generally consists of changing one or two lines of code per program, rather than changing each call to the database.

continue reading >>>
or jump to a topic:

Introduction
Unix or Windows NT?
Understanding What's Right for You
Choosing a Database
Connecting to the Database
Recap & Resources


view a printable version of this article


To suggest a topic, please email guides@ahref.com.

 


HOME ||| ABOUT AHREF.COM ||| ADVERTISE ||| FEEDBACK ||| SEARCH THIS SITE ||| CONTRIBUTE

© 1998-1999 ep Productions, Inc. All rights reserved. Terms of use.