Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.


Channels ▼
RSS

C Database Programming with ODBC


November 1995/C Database Programming with ODBC/Sidebar

What Is SQL?


SQL stands for "Structured Query Language." SQL started out as the query language for the System/R project at IBM's Santa Teresa laboratories in the mid-1970s. System/R was a project that grew out of Ted Codd's pioneering work on relational databases and was the forerunner of DB2. A relational database is a database organized around the table model, where rows correspond to what are commonly called records and columns correspond to fields. The logical model of a relational database is of a collection of tables, with no pointers — only key values. The database engine maintains pointers, to be sure, but these pointers are hidden from the developer. Having no explicit pointers and having an ability to dynamically modify its own structure (new tables, rows and even columns can be added at any time) makes a relational database conceptually simple and very flexible.

SQL is a simple database manipulation language built around a small number of statements. WHERE introduces a condition, as in WHERE Inventory < 30. SELECT retrieves data, as in SELECT MachineID FROM MACHINE which retrieves all the values of the column MachineID from the table MACHINE. UPDATE updates data, as in UPDATE MACHINE SET Capacity = 33 WHERE Inventory < 30 which sets the value of Capacity to 33 in all the rows of the table MACHINE where the value of Inventory is less than 30. DELETE deletes data, as in DELETE FROM MACHINE WHERE Inventory < 50, which deletes from the table MACHINE all rows where the value of Inventory is less than 50. In addition, SQL has statements to add or delete columns, to generate totals or sort rows, to join different tables to create a temporary table for query purposes, and to nest queries within queries. Most DBMSs include an interactive SQL processor, so that someone with no programming experiences can query and update a database. Of course, the DBMS also incorporates security safeguards to prevent the inexperienced and adventurous from having free reign of the company data.

The Growth of SQL

SQL's growth from a restricted query language to a full-scale database manipulation language has led to an explosive growth in the number of relational database engines. All of these engines attempt strict adherance to the ever-evolving ANSI/ISO SQL standards, but some engines also differentiate themselves by adding proprietary "improvements." SQL's strengths (flexibility and conceptual simplicity) are the sources of its weaknesses: inflexibility and lack of speed. Pointers buried deep in the inaccessible database structure are unavailable to programmers, and often go unexploited. It is the database engine and not the programmer who decides on an access plan. SQL's stubborn insistence on seeing the world in terms of independent context-free rows and columns makes it difficult to fully take advantage of structures as repeating groups. Still, you can't argue with success. None of the major DBMS vendors have strayed from SQL, and it seems likely to remain with us in its various standard forms for some time to come. Oracle, Ingres, Access, Paradox, Sybase, SQL Server, SQLBase, and other SQL DBMS vendors overwhelmingly dominate the marketplace.

Making SQL More Accessible

Embedded SQL was an early attempt at making SQL accessible from other languages. The programmer would embed SQL statements in his program and a preprocessor would translate them into something the language compiler (usually Cobol but sometimes C) could handle. Embedded SQL is very highly vendor specific, since each vendor supplies different interface functions and no attempt at portability has been made.

Microsoft published the ODBC specification in 1992, ostensibly in response to the call of the SQL Access Group (a vendor group) for a call-level interface to SQL. In 1993 Apple and Microsoft agreed to support ODBC on Windows and Macintosh, in effect ensuring ODBC's status as the standard call-level SQL interface.

Learning SQL

Most DBMS vendors include an introduction to SQL in their documentation. These books are usually well suited to those who are already familiar with the subject. You can also try your local computer bookstore. I have used and like The LAN TIMES Guide to SQL, by James R. Groff and Paul N. Weinberg, Osborne McGraw-Hill, 1994 [3].


Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.