Flat-File Databases versus Relational Databases: More than you will ever need to know A flat-file database consists of one table. A relational database comprises a number of tables that are linked by foreign-key relationships. In a flat-file database the same piece of information may be repeated lots of times, for instance a flat-file database showing product sales may show a product and its price each time a product is sold. That a product has a particular price is really just one piece of information and a relational database would only store it once, in a separate product table. The fact that a flat-file database stores this information once for every time the product is sold is an example of data redundancy. Data redundancy can cause problems in a database system, for instance if a product's name changes. In a flat-file database this change has to be made many times, but in a relational database it only needs to be changed once. Data redundancy can also lead to data inconsistency, for example if a new row is created and the product's price is entered wrongly. In this case some rows will give the product's price as one value and other rows will have a different value. Relational databases avoid data consistency problems by only storing each piece of information once. It is still possible to enter a "wrong" price for a product, but it is impossible for the price to be inconsistent if the database is designed properly. Other problems associated with data redundancy are firstly the extra time it takes for data entry (it takes time to write things out again and again) and secondly the extra disk space that this requires. Often a flat-file database will just be a CSV (comma-separated values) file. In this case it is impossible to assign different levels of access to different users. Even if the flat-file database is stored in a DBMS (database management system) it is not possible to implement the table-level access that relational databases allow. A final, and rather complex disadvantage of flat-file databases is that the user interface is dependent on the file structure. That means that if you want to create a different view of the data, just some of the fields say, then you have to create a new file. This is known as program-data dependence. In a relational database the file structure is totally unrelated to the table structure so it is possible to create all sorts of different views of the data to suit different users. Flat-file databases do have their advantages. Firstly, if the information is printed out it is much easier to read for a human than would be a set of relational tables. Secondly, because flat-file database software does not need to do lots of CPU-intensive look-ups to join a number of tables, queries can run much faster than in relational databases. The process of splitting information into separate tables so that there is absolutely no redundancy is called "normalisation". In practice it is very rare for a relational database to be fully normalised because of the effect this has on performance. Advantages Flat-file database 1. Fast data retrieval 2. Easier for a human to read Relational database 1. Less data redundancy 2. Less data inconsistency 3. Better security 4. Program-data independence Disadvantages 1. Duplicated data 2. Slower data entry 3. More disk space required 4. Data inconsistency is possible 5. Updates have to be done multiple times 6. Little or no access control 7. Program-data dependence 1. Slower data retrieval 2. Difficult to read original table data