Perl
Standards and guidelines
Lateral thinking
Frederick P. Brooks, Jr.
flat database
Where is the bottleneck in flat file databases?
Is it faster to access data from files or a database server?
Alternate Data Storage Technologies
Database Management Systems
Magic scripta  
text-based or flat file database
Database Programming with Perl


text-based or flat file database
A flat database is a database within a single file. A database is a set of data within a structure (in memory or a file, for example). All data stored in a database, is stored within validity constraints - that, in simple terms, means the data stored, is validated, and only stored if it passes a validation check.
Against popular belief, flat databases can be linked to another database, or joined; but for this tutorial, I will cover flat databases, without joining, in perl.

----------------------
Uses of databases
----------------------

Databases are commonly used to store bodies of data which are too large to be managed on paper or through simple spreadsheets. Most businesses use databases for accounts, inventory, personnel, and other record keeping. Databases are also becoming more widely used by home users for address books, cd collections, recipe archives, etc. There are very few fields in which databases cannot be used.

Chapter summary
A database is a collection of related information.
Data stored in a database is persistent
There are a number of different types of databases, including flat file, relational, and others
Database management systems are collections of software used to manage databases
Databases are widely used in many areas of application
------------------------
Types of databases
------------------------
There are many different types of databases, including:

Flat-file text databases
Associative flat-file databases such as Berkeley DB
Relational databases
Object databases
Network databases
Hierarchical databases such as LDAP
----------------------------------------------------------------------------------------------------
Storing databases:
I'm going to cover the theory to storing a flat database first, because it's the most important to understand, and it introduces you to storage concepts.
We know that validation checks to see if data is ok, but we don't know how to store information in a flat database. A structured (aka 'active' or 'online') database will store data in memory, and to disk. We do not have the option of storing to memory, because we are using a flat, off-line, database. Therefore, the entire database state, should be stored to file after being modified.
When storing to file, we need a method of storing the data so it can be read again. If the data cannot be read correctly, then there is no reason in storing it. There are two used methods of storing data.
- Chunks:
Chunks of data are often the fastest method of saving data, because they do not require any conditional formatting. A section of a 'chunk database' may look like the following:

29 data data more data even more data

Each field is on it's own line, and each line has a carriage return directly after the end of the data. If there is no data, where data should be stored, a carriage return is still used to 'hold' the database structure. The records are stored in lines of 5. In code, a data chunk is often referenced as an array.

-----------------------------------------------------------------
In fact, this is all you need to know to be a Caveman Database Programmer: A relational database is a big spreadsheet that several people can update simultaneously.
Let's examine how this works in greater detail.

Each table in the database is one spreadsheet. You tell the RDBMS how many columns each row has. For example, in our mailing list database, the table has two columns: name and e-mail. Each entry in the database consists of one row in this table. An RDBMS is more restrictive than a spreadsheet in that all the data in one column must be of the same type, e.g., integer, decimal, character string, or date. Another difference between a spreadsheet and an RDBMS is that the rows in an RDBMS are not ordered. You can have a column named row_number and ask the RDBMS to return the rows ordered according to the data in this column, but the row numbering is not implicit as it would be with a spreadsheet program. If you do define a row_number column or some other unique identifier for rows in a table, it becomes possible for a row in another table to refer to that row by including the value of the unique ID.

The table will be called mailing_list and will have two columns, both variable length character strings. We've added a couple of integrity constraints on the email column. The not null will prevent any program from inserting a row where name is specified but email is not. After all, the whole point of the system is to send people e-mail so there isn't much value in having a name with no e-mail address.

----
Databases are essential for record keeping. You can set up databases with database software packages, or even spreadsheet applications. Either way, both include options for database tables. Establishing database tables are a big part of database design, and the number of database tables is the main contrast between flat file and relational databases.
You can simply establish a database with one database table. One single database table can include all the database�s fields. And this is what a flat file database is, a single file database table.