Database Reference
In-Depth Information
same type. When you define the column, you specify the type of data within it. The next
chapter will describe some of the types of data that you can store in each column.
Rows, Records and Tuples
A row, a record and a tuple are all different ways of referring to a line of data within a table.
In this topic I will generally use the term row. The tuple is the relational theory term for a
row, and a record is the earlier form of databases term.
In Figure 1.2 the following could be described as a single row or record:
191.168.1.3 - - [07/Nov/2002:09:39:47 +0000] “GET /html/index.php
HTTP/1.1” 302 262
A lot of the data in the log is the same for each row; in fact, in the excerpt we have shown,
the only thing that changes is the time. This is not actually a very efficient way of storing
this information, as so much of it is static. We will deal with storing this in a better way in a
later chapter.
Relations
We have already stated that the relational theory term for a table is a relation. However,
tables in relational databases can have relationships between them. Look again at the last
but one column of the log file in Figure 1.2. It contains the number 302. This column stores
a number that represents the message that the system is logging. For instance, if you request
a page that is not on a webserver, you may be familiar with receiving a 404 error. This num-
ber represents the error condition: Not found . In fact the 302 message represents the condi-
tion: Moved temporarily. Table 1.1 shows some more of these conditions
Table 1.1
Webserver status codes.
Code
Condition
200
OK
300
Multiple choices
302
Moved temporarily
401
Authorization required
403
Forbidden
404
Not found
Imagine that Table 1.1 was stored as a table in a database. Every time that the webserver
added a row to its log table, it could log the status condition for the log entry by adding the
string “Moved temporarily”, or it could add the numeric code from Table 1.1 to the log
entry instead. Apache uses the latter approach. It includes a code in the log file that can be
used to look up another value in another table. These two tables are therefore related to
each other. They are related in that an entry in one table is a key to an entry in another.
Most databases claim to be relational ones. There is much debate as to what makes a
database relational or not, and many claims that a database system is relational are dis-
 
Search WWH ::




Custom Search