Internet
Fact-checked

At EasyTechJunkie, we're committed to delivering accurate, trustworthy information. Our expert-authored content is rigorously fact-checked and sourced from credible authorities. Discover how we uphold the highest standards in providing you with reliable knowledge.

Learn more...

What is a Flat File?

Derek Schauland
Derek Schauland

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

Woman doing a handstand with a computer
Woman doing a handstand with a computer

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.

Discussion Comments

anon288901

Flat files are very important in ETL (Extract, Transfer, Load).

anon288240

Flat files are used all the time. In fact, in data mining, flat files are the norm.

Other examples: readings of temperatures, speed at impact, velocities. Anything that has a large number of entries and a short and constant number of fields is best stored in a flat file.

I even have a dirty little secret about databases. If you need a database, but all your information can be stored in a single table, the fastest way to store your data is in a flat file. A relational database has a big handicap in the access of data because it has to check constraints and relations and search tables, and ultimately, everything is stored in files, anyway. A flat file has nothing of that.

anon232495

Consider the mobility.

narnia219

The only place I ever still see a flat file used @famnfriends, is in downloading information from my bank account to Excel. They always give the CSV option, and it is usually the only one that is compatible with Excel. So, I guess that it still has a place there, but I cannot imagine many other situations, if any, where it could possibly be useful.

famnfriends

This is very interesting. It makes sense to use the relational file. The flat file was a great start in our technology, but it would be really cumbersome to use when you have a lot of information that you want to cross check. Is there a place for it still or is the flat file obsolete?

Post your comments
Login:
Forgot password?
Register:
    • Woman doing a handstand with a computer
      Woman doing a handstand with a computer