 |

Database Files
To start using WebCatalog, we have to store some data in a file for
WebCatalog to play with. Is there anyone in the audience today that
is unfamiliar with what a database is? Here's the short answer - a
database is a file containing a list of similar information. (If you
scroll down a little, you'll see what I mean.) The biggest chore of
creating a database is decided what information you are planning to
store, and how to organize it inside the database file. For the BASICS
part of this WebCat guide, we will deal with simple databases. In
some of the advanced sections, you will learn some more complicated
ways to store complex data into your database files.
While there are three
variations to WebCatalog's internal databases, we will start with
the easiest, a tab delimited database with the headers in the database
file. The first line of the file contains the names of the fields that
will hold the data. Each field name is separated by a tab character.
Each field name contains no spaces, and is meaningful. On the second
line, and all that follow, is the actual data.
This database is called listings.db. In WebCatalog, databases should
generally end in .db. If you make a database name end with another
extension, you will most likely need to reconfigure WebCatalog to
recognize the file as a valid database file.
For those of you
who have other experience with databases, you may be wondering where
the rest of the information about the database is stored. (like
the indexes.) In WebCatalog there is no such thing. Because these
are RAM stored databases, these other parts (like indexes) aren't
strictly needed, and would just add complexity and overhead.
Our First Database
We have to start somewhere, so we're going to pretend that we have
a client who wants a real estate website. The first concept we are
going to learn is searching a database to show content on a web
page. Let's say that we given a list of of 10 houses that want to
be listed for sale. The first thing we have to do is put them into
a database that WebCatalog can understand. For
the purposes of this guide, I will be illustrating the database
structure with spaces to improve legibility, your databases will
not look like this (in most text editors) when done properly.
listings.db
Address City Zip Bedrooms Baths Sq_Ft
123 West Main Parsippany 07054 3 2.5 2000
13 Oak Street Parsippany 07054 1 1 950
48 Rock Ave Huntsville 08943 2 2 1700
836 Main St Dover 07652 4 3 2400
99 Century Blvd Rockaway 07924 2 2 1500
7 Lucky Lane Dover 07652 5 5.5 3500
432 Beverwyck Dover 07652 3 1 2200
88 Eighth Ave Parsippany 07054 2 3 880
62 Valley View Rockaway 07924 1 2 1200
Route 3 Box 52 Newton 08876 3 2.5 2200
This beginning database
could be quickly put together in just about any text editor, (such
as BBEdit
for the Mac, or TextPad
for the PC) or as a tab delimited export of a spreadsheet from Excel.
On thing I have noticed is that the server likes to have databases
where the line endings are matched to that server type (i.e. Macs
like lines that end in a <CR> while Unix computers like lines
that end in <LF> and PC servers like lines that end in <CR><LF>)
your mileage may vary, but talk to your server administrator about
this if a newly created database doesn't seem to be working correctly.
Don't stop now, the
ride is just beginning...
<--
Previous Index Next
-->
HOME | Basics | Advanced | Training | Rants+Raves | Links | Feedback
This
whole page, and everything on it ©2001 Brian
B. Burton. This page and the text contained herein may not be
reproduced on any other site, or via any other means. Really, how
hard is it just to link to this site, so people get to see the latest
updates? http://www.burtons.com/webdna/ Thank You.
Site design by Clint Davis.
Thank You Clint!
|