 |
|
SQL and Relational Databases
Oracle Database Tips by Donald Burleson
|
Dr. E. F. Codd first introduced the
concept of the Structured Query Language (SQL) as part of his early work
on the relational database model. Dr. Codd was famous for his creative
names for his concepts and his rationale for naming SQL is no
exception. For example, Codd named the process of relational database
design "normalization" because President Nixon was normalizing relations
with China at the time, and Dr. Codd reasoned that if Nixon could
normalize relations between countries then he could normalize relations
between data relations. The naming of the relational query language as
SQL is another great misnomer. One should note that SQL is NOT a query
language. SQL performs much more than queries (SQL allows updates,
deletes, and inserts), and SQL is also not a language, (SQL is embedded
within procedural languages such as Cobol or "C"). Consequently, the
name of Structured Query Language seemed a logical name for Dr. Codd's
new tool.
Regardless of the appropriateness of the name,
SQL offers three basic classes of operators, SELECT, PROJECT and JOIN. The
SELECT operator serves to shrink a relational table vertically by eliminating
unwanted rows. The PROJECT operator serves to shrink the table horizontally,
removing unwanted columns, and the JOIN operator allowed the dynamic linking of
two tables which share a common column value. Most commercial implementations
of SQL do not support a PROJECT operation, and projections are achieved by
specifying the columns which are desired in the output. The JOIN operation is
achieved by stating the selection criteria for two tables, and equating them
with their common columns.
In its day, the SQL language was a revolution.
It was no longer necessary to manually navigate the database, one record at a
time in order to resolve a database request. The new features of the SQL
language included:
Data Access Flexibility.
The data resides in freestanding tables, which are not hard-linked with other
tables. Columns can be added to relational tables without any changes to
application programs, and the addition of new data or data relationships to the
data model seldom require restructuring of the tables.
Declarative Data Access.
Database navigation is hidden from the programmers. When compared to a
navigational languages such as CODASYL DML, in which the programmer was required
to know the details of the access paths, relational access is handled with an
"SQL" optimizer, which takes care of all navigation on behalf of the user.
Relational data access is a "state space" approach, whereby the user specifies
the Boolean conditions for the retrieval, and the system returns the data which
meets the selection criteria in the SQL statement.
A Simple Conceptual Framework.
The relational database is
very easy to describe, and even naive users can understand the concept of
tables. Complex network diagrams which are used to describe the structure of
network and hierarchical databases are not needed to describe a relational
database.
Referential Integrity (RI).
Relational systems allow for the control of business rules with "constraints".
These RI rules are used to insure that one-to-many and many-to-many
relationships are enforced within the relational tables. For example, RI would
insure that a row in the CUSTOMER table could not be deleted if orders for that
customer exist in the ORDER table.
One of the greatest benefits of the relational
databases is the concept of data independence. Because data relationships were
no longer hard-linked with pointers, systems developers were able to design
systems based upon business requirements with far less time being spend on
physical considerations.