September 22, 2009

What is ODBC ?

ODBC is Open Database Connectivity, a standard Database access method developed by Microsoft Corporation. It is in fact an API that acts as a tool to access data from any application irrespective of which DBMS (Database Management system) is handling the data. The location of this layer will be more clear from the following diagram





If you see it clearly, from the top hierarchy goes like this: 
Application Layer [including ODBC API] --> Driver Manager Layer --> Driver Layer --> Data Source Layer

Now let's see in brief , what are these layers all about. :)

Application Layer : It consists of GUI components and its basic purpose is to call functions of ODBC API that converts SQL statements and connect to datasources and then retreive results and then disconnect.

ODBC API: As already mentioned in above point only, it consists of functions which are called by Application layer. These functions are responsible for translating application's data queries into commands that can be easily understood by DBMS.

Driver Manager Layer: It manages the loading of various drivers available in the system. Also it passes the requests to the appropriate drivers existing in next driver layer.

Driver Layer : This layer basically consist of many ODBC drivers e.g. Access Driver, SQL Server Driver, Oracle Driver etc.. It executes ODBC function calls and submits SQL requests to the data source and results to the application.

Note: You can also check the default Drivers installed in your system by Microsoft [of course if have Microsoft 's OS]. 
Go to Control Panel -> Administrative Tools ->Data Sources (ODBC) -> "Drivers" tab. You will see dialog box something like below.




Data Source Layer: It consists of the data and its associated database engine. It processes the request sent from Driver layer and thus generate final results which are passed back to the application.

Let's have a short look on how exactly this ODBC thing works and at the end its pros and cons :

1. Processing of ODBC [in brief]  
In order to use ODBC, three basic components are needed - ODBC client, ODBC Driver and a DBMS server.

ODBC Client uses a command[ODBC API] to interact with DBMS server like Microsoft Access, SQL Server, Oracle etc..].But DBMS server cannot directly understand ODBC commands so in order to make the commands understandable to DBMS servers, ODBC Driver comes into picture. It translates or decodes the commands such that they can be easily processed by DBMS[or often called as ODBC] servers. After processing , ODBC server sends the results to same intermediary ODBC Driver which translates it into appropriate form and show it to the ODBC client.

2. Advantages of ODBC : Being a universal data access interface,  it gives independent s/w companies an advantage in that they need not to learn multiple application programming interfaces(APIs) . ODBC allow their applications to simultaneously access, view and modify database from wide spread variety of databases.

3. Disadvantages of ODBC : When so many drivers are being used, an overhead of managing them is also increased.

Hope you are able to follow what I tried to tell. In case, have any issues or queries fire them. :)

Thanks !