Flat Files Vs. Database

Save

What's the difference between a flat file and a database? This question is actually a contradiction in terms, because a flat file is a type of database. It's easy to confuse the terminology because modern database technologies such as SQL and FoxPro use a much more sophisticated relational database structure for organizing records. Many modern software systems only use flat files as a temporary holding area for data being exported and imported to modern, relational data sources.

Flat File Database

  • Consider the following lines of text:

    0001
    0002
    0003

    If you were to copy and paste these into a plain-text file and save the document, you would have created a flat file database. A flat file database is nothing more than a list of records. Obviously, the database created in this example wouldn't be a very useful or meaningful one, but it would be a valid flat file database with three records.

    If you're confused because this just looks like a text file, you're absolutely right. A flat file database really isn't a functional database at all until an external program parses, loads and interprets or manipulates the data. In the example above, we would need to have some software that specifically completes its tasks based on 4-digit numerical database records.

    "Flat file" does not refer to a standard, a technology or a language. "Flat file" is just a general concept that describes an "old school" style of database that was used before the advent of relational tables and schemas.

Multi-Field Records in a Flat File

  • A text file containing the following lines would also be a valid flat file database:

    1234,X
    2468,X
    4321,Y
    8642,Y

    This would be an example of a comma-delimited flat file. Each record now contains two fields instead of one. In our first record, the data "1234" is associated with the data "X".

    Delimeters do not need to be commas. Again, everything depends on the software that interprets the flat file database. A semicolon-delimited flat file used to store customer addresses might have records like:

    LEON WILLIAMS;123 ANYWHERE TERRACE;AMERICATOWN;WI;12345-0000;USA
    JOHN DOE;000 NOWHERE PLACE;HIDDEN VALLEY;MT;00000-1234;USA

Relational Database

  • Modern database formats such as SQL use relational database technology. A relational database means that the field definitions and relationships are defined within the database itself, and not by an external software process. This is done by including key records to define data internally. (You can think of key records like column headers on a spreadsheet; they explain or label the data listed below them.)

    For example, a SQL table used to store customer addresses may define key records like "name," "street," "city," "state" and "zip." The data in each record is then defined by these keys rather than existing as strings of free-floating data in a text file.

Modern Usage of Flat Files

  • In modern computing, a flat file is more likely to be a temporary file used when importing and exporting data. For example, exporting from a SQL database to a FoxPro database may require complicated and expensive processes. It is often easier to export the SQL data to a flat file, and then build that flat file into a FoxPro database. Obviously, this also requires special software, but the use of flat files as a go-between eliminates the need for a customized, direct interface between the two relational data sources.

Editing Flat Files

  • Another reason for exporting a relational database to a flat file is that it makes the data easy to edit from any workstation. If you work with your data in flat file form, you can simply open it up in your favorite text editor and make changes as needed. You therefore eliminate the need for the special software and special knowledge you would need to query and edit a SQL database directly.

References

Promoted By Zergnet

Comments

You May Also Like

Related Searches

M
Is DIY in your DNA? Become part of our maker community.
Submit Your Work!