A flat file is a collection of information stored and accessed sequentially in a database, often created to store information in a non-structured way. Comma Separated Value (CSV) sheets, for example, present information with each field separated from the next by a comma. While a flat file system offers some advantages, it often makes large amounts of data quite cumbersome to store and access. The majority of databases used today are relational systems that use structured queries to retrieve information and present it to the user.
How It Works
To make a flat file data model functional, all relevant information about a record needs to be stored in the same file. In a CSV sheet, for example, no application-specific formats apply to the data contained within the file; only a comma denotes the end of one field in a record. Each record is written on a line in the file, allowing all data for a single record to be stored separately from other records.
Such databases can quickly become very large and difficult to manage because of the simple way they are organized. Many modern data models use connected tables to organize groups of related data. This makes such information easier to locate and more flexible to work with.
Using a Flat System
If a customer calls a business to place an order, then someone enters his or her information into a table or database. That same person, or someone else, then enters information for that particular order. A flat file system might store all of this information for the customer in a single file.
This is not necessary, however, so multiple files could be maintained: one for the customer, and one for each individual order. Information about an order stored in one flat file is not associated with information about the customer stored in a different one. These files are not related in any way, so someone using a flat file database to find customer information can easily miss additional files about orders.
Weaknesses of This System
Since each record needs to be complete in and of itself, a flat file system usually results in very large files or a lack of connectivity between information within it. The common database used today is a relational database. This model allows information in one table to be related to other tables using key fields which exist in each one. Multiple tables become connected through these fields, allowing each one to have only part of the total information needed.
Relational Databases
The same customer example given above might look quite different in a relational model. When the customer calls to place an order, someone enters his or her information in a "customer" table within the database. Another person can then enter information for his or her order in a separate table. Each of these tables include fields that connect them to each other. This means that someone can use the system to more easily find all of the information for a customer, including total order history.
Continued Use
Flat file databases do have some uses, even though the functionality of this data model is not quite as efficient as a faster, relational approach. Simple systems can easily contain basic information for a quick database. The lack of connected fields also eliminates errors that can arise from missing tables, so many downloadable databases use this format to avoid such issues.