7.16. SQL AND ORACLE

7.16.1. INTRODUCTION

Oracle, in the most-used sense, is a relational database product. Actually, it is a multi-billion dollar company which provides a number of different services and products, one of which happens to be a relational database called Oracle.

As mentioned above, Oracle is a relational database, which means that there exists special relationships within the data. In a relational database, only the data should change, not the structure.

For example, in the traditional database approach there would exist a master file which would contain a large number of records. Each record would be broken down into fields. The programs that make use of this database would be programmed around the structure of the records in the master file.

name1           phone1          address1        soc-sec1        age1            
name2           phone2          address2        soc-sec2        age2            
...             ...             ...             ...             ...             
nameN           phoneN          addressN        soc-secN        ageN            

Master file record layout for traditional database approach.

What happens when a new field needs to be added? A re-write of portions of the code would be necessary -- any part associated with the master file and any part associated with record structure would need to be updated. The associated costs in terms of money and time could be great, and any mistake could cause an inability of the business to function properly.

In the relational approach there is really no such thing as a master file. Instead, all the data are stored in tables. System designers isolate the different data into logical, usually small groups that share some type of relationship and then generate the tables which will contain all the information.

soc-sec1        name1           
soc-sec2        name2           
...             ...             
soc-secN        nameN           

soc-sec1        phone1          
soc-sec2        phone2          
...             ...             
soc-secN        phoneN          

soc-sec1        address1        
soc-sec2        address2        
...             ...             
soc-secN        addressN        

soc-sec1        age1            
soc-sec2        age2            
...             ...             
soc-secN        ageN            

Tables for a relational database.

The relational approach takes more time up front -- to deconstruct the data and define the relationships, but once implemented any changes that might need to be made can be done through the deletion or addition of a table.

Another major problem that relational databases solve is that of synchronization. In the traditional approach a change made to one master file might have to be carried through to other master files. This is one of the most difficult things to ensure in the traditional approach. Even if a traditional database product has automatic propagation it may still take days for the changes to make their way through the system. In the relational approach, synchronization is a non-issue since all the data resides in one-and-only-one location.

Where does SQL fit in? SQL is a programming language that stands for Structured Query Language. Some people pronounce it sequel. It is one of a number of languages designed for use with relational databases, but this one has become the adopted standard by all database vendors.

Oracle makes use of a version of SQL called SQL*Plus, a superset of regular SQL. Any interaction that takes place with Oracle is done through these SQL statements. This means that you can interact with Oracle through other programs as long as they can produce SQL output to be sent to the Oracle Server.

When you work with SQL, your commands operate on a set of data consisting of groups of rows and columns. This differs from the traditional approach where data is processed a single record at a time. Using SQL you can write simple one-line queries to the database or large complex programs capable of substantial data processing.