|
How is a database structured?
Most DBMSs in use today, both on the Internet and off, are relational
databases that use the SQL language for queries. Structured Query Language (SQL) is a relatively simple language
which you can use to access most relational databases. Various vendors have
implemented their own extensions to SQL, but most of the language is standard regardless of what
DBMS you use. IBM released the first commercial version of SQL
in the early 1980s, and it has been adopted by almost every relational
database vendor since then.
A relational database stores information in tables. Each table stores information about a set of similar things, such as the web sites in our Index. A table contains a set of fields with information about their attributes. For example, in our Index database there is a field for "URL." This field has an attribute describing what sort of characters should be entered (numbers, letters, and so on).
The tables in a relational database are generally related in some way (which probably has something to do with the name). Tables may be related conceptually; for example, you may put them in the same database
because they deal with the same general system. In one database on this site, we have a table called
website (for use in the Index) and another called message (for use in our discussion forums). They are in the same database so that, in future, we can tie these areas together, perhaps by including users' comments about sites we include.
Here's what the website table in our Index looks like:
|
FIELD
unique_id
url
title
sort_title
description
organization_id BR>
mod_date_stamp
create_date_stamp
date_last_visited
|
TYPE
int(11)
varchar(255)
varchar(255)
varchar(255)
varchar(255)
int(11)
timestamp(14)
timestamp(14)
date
|
In this table, unique_id, url, and the other items in the left column are field names. The right column contains the attributes for each field, or what should be entered (numbers, letters, and so on). For example, for the field unique_id, the attribute int(11) specifies that numbers (integers) should be entered. Each web site we add to our Index is given a unique identifying number.
The url and several of the other fields are text strings. MySQL has an attribute
called varchar which allows for up to 255 characters to be entered (which would be expressed as varchar(255). You can set the maximum number of characters allowed; for example, if you wanted 150 to be the maximum, you could express it as varchar(150). This way, the database acts as your watchdog, allowing only the number of characters you set.
|
|