A flat file contains records that have no structured interrelationship. A flat file typically consists of a text file, from which all word processing or other structure characters or markup have been removed.
Flat file database vs. relational database
A flat file is often mistaken for a relational database, but they are actually much different. A flat file consists of a single table of data. It allows the user to specify data attributes, such as columns and data types table by table, and stores those attributes separate from applications. This type of file is commonly used to import data in data warehousing projects.Content Continues Below
In relational databases, flat file is sometimes used as a synonym for a "relation." A relational database contains multiple tables of data that relate to each other and allows the user to specify information about multiple tables and the relationships between those tables, allowing more flexibility and control over database constraints.
Types of flat files
There is some ambiguity about whether markings such as line breaks can be included in a flat file. In any event, many call a Microsoft Word document that has been saved as text only a flat file. The resulting file contains records (lines of text of a certain uniform length) but no information, for example, about what size to make a line that is a title or that a program could use to format the document with a table of contents.
However, it does require the application to have knowledge of how the data is organized within the file. By using structured query language (SQL) and a database, rather than a collection of files in a file system, a user or an application doesn't need to understand the location and layout of data (the length of each item of data, its type of data and its relationship to other data items).
One of the most prominent flat file examples is a comma-separated values (CSV) file. A CSV file is one in which table data is gathered in lines of American Standard Code for Information Interchange (ASCII) text with the value from each table cell separated by a comma and each row represented by a new line. A CSV file is one of the most common flat files, as it represents relational data in a text file.
Another flat file example is a delimited file that contains one or multiple records that are separated by a specific character, such as a tab.