Tuesday 3 March 2015

Relational and Flat-file Databases

A DBMS that uses only a single table is called a flat-file database.  But a DBMS can go further: Several tables can be related to each other and the DBMS can access them in a synchronized way to create highly detailed analyses and meaning ful relationships between their various fields(or subsets of fields).

In other words, the DBMS takes raw forms relationships that turn it into useful information. This ability to synchronize relationships between tables is far easier for a computer than a human being. 
To visualize how a computer works with related tables in a database, imagine a company that ships a variety of products to customers,  The company maintains a table of customers, including a customers ID number, name and shipping addresses.  If the company had to add a field to the customer table each time a customer ordered a product, the table would quickly become bloated, full of fields that not all customer records would necessarily need.

Instead product numbers, names and prices are stored in a separate inventory table.  When a customer orders products, just product numbers, long with customer's ID number, are copied into the third table, a shipping/invoicing table.  This third table is very small because only the relevant ID numbers are duplicated.  The shipping/invoicing table can be sorted on the customer's Id number and invoice number, to keep all the ordered items together.  The details about the customer and the products remain in their respective customer and inventory tables.  The DBMS can print shipping orders and invoices based on the small table, using the ID numbers to look up the details about customers and products remain in their respective customer and inventory tables.

The DBMS can print shipping orders and invoices based on the small table, using the ID numbers to look up the details about customers and products, While this process would be tedious for human beings, it is easy for a computer.  The relational databases saves disk space especially as shipping and invoicing records accumulate.  The shipping/invoicing table,with its tree fields is much easier for a computer to sort and maintain than a single table with many fields.  The multiple file the relational database model can be applied to  many different types of business record keeping.  For example, you can relate a mailing list to a set of a demographic categories, a single student to multiple records to classes taken and grades received; a single accounting code to multiple instances of expenses and income, and so on.