SQL
Structured Query Language (SQL) is a domain-specific language used in programming and designed for managing data held in a relational database management system (RDBMS), or for stream processing in a relational data stream management system (RDSMS). It is particularly useful in handling structured data, i.e., data incorporating relations among entities and variables.[1]
SQL offers two main advantages over older read-write APIs like ISAM or VSAM: it introduced the concept of accessing many records with one single command, and it eliminates the need to specify how to reach a record (e.g., with or without an index).
History
SQL was initially developed at IBM by Donald D. Chamberlin and Raymond F. Boyce in the early 1970s.[2] This version, initially called SEQUEL (Structured English Query Language), was designed to manipulate and retrieve data stored in IBM's quasi-relational database management system, System R.
In the late 1970s, Relational Software, Inc. (now Oracle Corporation) saw the potential of the concepts described by Chamberlin and Boyce and developed their own SQL-based RDBMS for the enterprise market. In June 1979, Relational Software introduced Oracle V2, the first commercially available implementation of SQL.[3]
Language Design
The SQL language is sub-divided into several language elements, including:
- Clauses: Constituent components of statements and queries (e.g.,
SELECT,FROM,WHERE). - Expressions: Can produce either scalar values or tables consisting of columns and rows of data.
- Predicates: Specify conditions that can be evaluated to SQL three-valued logic (3VL) (true/false/unknown) or Boolean truth values.
- Queries: Retrieve the data based on specific criteria.
- Statements: May have a persistent effect on schemata and data, or may control transactions, program flow, connections, sessions, or diagnostics.
Data Manipulation Language (DML)
The Data Manipulation Language is the subset of SQL used to manage data within existing schema objects. The most common DML statements are:
SELECTto retrieve data.INSERTto add data.UPDATEto modify data.DELETEto remove data.
Data Definition Language (DDL)
The Data Definition Language allows users to define and modify the structure of the database.
CREATEto build a new database object (like a table).ALTERto modify an existing database object.DROPto destroy a database object.
Syntax Example
A standard SQL query to retrieve data looks like the following:
<syntaxhighlight lang="sql">
SELECT employee_id, first_name, last_name
FROM employees
WHERE department_id = 50
ORDER BY last_name;
</syntaxhighlight>
Standardization
SQL became a standard of the American National Standards Institute (ANSI) in 1986, and of the International Organization for Standardization (ISO) in 1987.[4] Since then, the standard has been enhanced to include a larger number of features. Despite the existence of standards, most SQL code requires at least some modifications before being ported to different database systems due to proprietary vendor extensions.
Alternatives and Complements
While SQL remains the dominant language for relational databases, other paradigms exist. Object-relational mapping (ORM) frameworks allow developers to interact with databases using object-oriented programming languages instead of writing raw SQL.
Additionally, alternative graphical query approaches were developed around the same time as SQL to simplify user interaction. The most notable alternative paradigm is Query by Example (QBE), a graphical database query language for relational databases that allows users to search for information by entering template values into a visual table rather than writing text-based command statements.[5]
References
- ↑ Chamberlin, Donald D.; Boyce, Raymond F. (1974). "SEQUEL: A Structured English Query Language". Proceedings of the 1974 ACM SIGFIDET Workshop on Data Description, Access and Control: 249–264.
- ↑ Chamberlin, Donald D. (2012). "Early History of SQL". IEEE Annals of the History of Computing, 34(4): 78–82.
- ↑ Oracle Corporation. (2009). "Celebrating 30 Years of Oracle Database". Enterprise Database History.
- ↑ International Organization for Standardization. (2023). "Information technology — Database languages — SQL — Part 1: Framework (SQL/Framework)" (ISO/IEC 9075-1:2023).
- ↑ "Query by Example". Available online at alfawiki.org