Thursday, May 13, 2010

Introduction to RDBMS and advantages over simple text file

RDBMS is relational database management system in which information is stored using relational model. The basic idea behind relational model as introduced by E.F. codd is that we can store the information in such a way that we can access and get that information properly in future. That means all data must be accessible and information should be represented in one and only one way.

The purpose of the relational model is to provide a declarative method for specifying data and queries: we directly state what information the database contains and what information we want from it, and let the database management system software take care of describing data structures for storing the data and retrieval procedures for getting queries answered.

Flat File Database
A flat file database is a database designed around a single table. The flat file design puts all database information in one table, or list, with fields to represent all parameters. A flat file may contain many fields, often, with duplicate data that are prone to data corruption. If you decide to merge data between two flat files, you need to copy and paste relevant information from one file to the other. There is no automation between flat files. If you have two or more flat files that contain client addresses, for example, and a client moved, you would have to manually modify the address parameters in each file that contains that client’s information. Changing information in one file has no bearing on other files. Flat files offer the functionality to store information, manipulate fields, print or display formatted information and exchange information with others, through email and over the Internet. Some flat files may be attached to external files, such as text editors, to extend functionality and manage related information.

Relational Database
A relational database, on the other hand, incorporates multiple tables with methods for the tables to work together. The relationships between table data can be collated, merged and displayed in database forms. Most relational databases offer functionality to share data:

Across networks
Over the Internet
With laptops and other electronic devices, such as palm pilots
With other software systems
Designing flat file databases is simple and requires little design knowledge. Flat files can be developed using just about any database engine. Flat files can be created in relational database engines by not taking advantage of relational design concepts. Designing a relational database takes more planning than flat file databases. With flat files, you may add information, as you deem necessary. With relational databases, you must be careful to store data in tables such that the relationships make sense. Building a relational database is dependant upon your ability to establish a relational model. The model must fully describe how the data is organized, in terms of data structure, integrity, querying, manipulation and storage.

Relational databases allow you to define certain record fields, as keys or indexes, to perform search queries, join table records and establish integrity constraints. Search queries are faster and more accurate when based on indexed values. Table records can be easily joined by the indexed values. Integrity constraints can be established to ensure that table relationships are valid. If you are able to establish a one-to-many relationship in your data tables, you should be using a relational database because a flat file is not sufficient to handle your data processing needs.

Relational databases offer more robust reporting with report generators that filter and display selected fields. Relational databases offer the capability to build your own reporting modules. Most relational databases also offer the capability to import and export data from other software.

There are three primary relational database systems, proprietary, open source and embedded. Proprietary relational databases require the use of proprietary development languages, often times, to complement SQL. Microsoft Access, for example, combines Visual Basic with SQL. Open source databases, such as MySQL, are distributed freely to encourage user development. Embedded, relational databases are packaged as part of other software packages, such as with tax-preparation software packages. The vendor supplies the database, and all manipulation tools, to control the database structure. These databases are, often times, accompanied with tools to provide audit trails of transactions.

A database is optimized for data storage and data retrieval. When you put data into a database table, the database table can be indexed in a variety of ways so that depending on what column or columns you are searching by, the data can always be found as quickly as possible.

One of the ways that the databases do this, is by loading as much data into RAM as possible into what is called the buffer cache. This cache holds all the data that has been recently used within the database, so that it can be found faster than by looking for it on the disk. As the data in the cache becomes unused it is marked to be flushed so that if new data needs to be loaded into cache the database can make room for it.

Databases have been a staple of business computing from the very beginning of the digital era. In fact, the relational database was born in 1970 when E.F. Codd, a researcher at IBM, wrote a paper outlining the process. Since then, relational databases have grown in popularity to become the standard.
Originally, databases were flat. This means that the information was stored in one long text file, called a tab delimited file. Each entry in the tab delimited file is separated by a special character, such as a vertical bar (|). Each entry contains multiple pieces of information (fields) about a particular object or person grouped together as a record. The text file makes it difficult to search for specific information or to create reports that include only certain fields from each record. Here's an example of the file created by a flat database:

Lname, FName, Age, Salary|bhuva, dharmendra, 21, 5000|gogari, harsh, 22, 10000|peerzade, amrin, 21, 5000|kadam, vijay, 21, 5000|prasad, rohit, 22, 5000

You can see that you have to search sequentially through the entire file to gather related information, such as age or salary. A relational database allows you to easily find specific information. It also allows you to sort based on any field and generate reports that contain only certain fields from each record. Relational databases use tables to store information. The standard fields and records are represented as columns (fields) and rows (records) in a table. Look at this example:

LName FName City Age Salary
Bhuva Dharmendra 3 21 5000
Gogari Harsh 1 22 10000
Peerzade amrin 3 21 5000
Kadam Vijay 4 21 5000
Prasad rohit 2 22 5000

In the relational database example, you can quickly compare salaries and ages because of the arrangement of data in columns. The relational database model takes advantage of this uniformity to build completely new tables out of required information from existing tables. In other words, it uses the relationship of similar data to increase the speed and versatility of the database.
The "relational" part of the name comes into play because of mathematical relations. A typical relational database has anywhere from 10 to more than 1,000 tables. Each table contains a column or columns that other tables can key on to gather information from that table. Look at the table below that matches the number in the City column of the above table with the name of a city.

City # City Name
1 Pune
2 Mumbai
3 Ahmedabad
4 Los Angeles

By storing this information in another table, the database can create a single small table with the locations that can then be used for a variety of purposes by other tables in the database. A typical large database, like the one a big Web site, such as Amazon would have, will contain hundreds or thousands of tables like this all used together to quickly find the exact information needed at any given time.

No comments:

Post a Comment