Even though many advanced database programs are available, you will need to know a bit about a plain text database. They are still used a lot behind the scenes.
A list works well for information about how a program was installed or what the current configuration is.
The example in the illustration is a configuration file from Google Earth.
This type of file does not have rows and columns. The whole file is a database
with only one record. Each field is on a separate line in the format:
fieldname=value.
The parts between brackets [ ] are section titles.
The lines that start with two slashes // are comments and are ignored by the computer.
A log file is a text database that keeps a list of activities, like computer errors, program updates, or web site activity.
The example below is part of a log of the requests on a certain day to the web server that hosts these lessons. Each web page or image that the browser needs is a separate request. It looks more like what we expect from a database than the previous example, apparently having rows and columns, separated by spaces.
View full document
[Image] document in Notepad
[Image] horizontally scrolled document in Notepad
Each record is on one line. The fields appear to be neatly lined up in columns... until you scroll to the right. In some fields the values all have the same number of characters, but in other fields some values have many more characters than others. No more columns.
The first line above the records shows the names of the fields, but the names do not line up over the correct 'column'.
Row of field
names: Some text databases do not include the names of the fields as
the first row, or any row at all! If
you use a text database to move data between programs, you will need to
know whether or not the first record holds the field names.
Problem: Can't
see all of the fields in a single record at once:
When word wrapping is off and there are a lot of fields, you have to
scroll horizontally to see all of them. So awkward!
Solution:
Turn word wrapping on.
In Notepad: choose | .
But...when word wrapping is turned on, the fields no longer line up in columns. You can now see a complete record in the window at once, but it is much harder to read.
So, you get to choose one or the other:
See all of one record at once
OR
Have the fields line up (maybe).
Text databases need a way to separate the records from each other and to separate the fields in a record. A character that separates data items or records is called a delimiter.
Example: The illustration at the right is of a log of updates to Windows.
What marks the start of a new record?
Show Answer:A new line
character separates records. This character is not visible in text editors!
What separates the fields?
Show Answer: A TAB
separates these fields.
In General:
Records: Most text databases use an invisible new line character to separate records.
Fields: Several different characters are used to separate fields by different programs. You can not mix and match in the same document! Just one kind of field delimiter per document.
comma | , |
pipe | | |
semi-colon | ; |
TAB | |
space |
Warning: Delimiter character
appearing in a data value scrambles the database!
There are usually ways to have your chosen delimiter
anyway, by using escape characters or quotes, but the database designer must think ahead carefully!
Transferring data: When you
export data to a text database, you must choose a format and you may have a
choice of what to use as a delimiter. When you open that text file in a
different program, you will have
to tell the program what the delimiter is. Some programs do not recognize
all of the delimiters listed above, but commas and tabs are almost
certainly acceptable.
Link: Statistics in CSV format
A
format that is often used when transferring data between programs is CSV
format
(Comma Separated Values). This format puts a
comma between each field, like the example at the right. If a field is empty, all you see is the commas that divide it from its neighbors.
The file may use csv as the file extension, like mydata.csv
CSV format is easy for computers to use, but it not easy for human eyes!