SQL (Structured Query Language)

Structured Query Language (SQL; pronounced "S-Q-L" or "sequel") is an interactive programming language that allows users to find and change information in databases. SQL is a language that manages and accesses information from databases, yet it is not comprehensive enough to create programs. First developed in the 1970s, SQL became the most popular query language used to access information. SQL has been enhanced over the years to keep up with changing technology. However, new technology has made other query languages more popular for some database management.

87322820-100218.jpg

History of SQL

Before the development of SQL, companies and organizations used database management systems (DBMS) to build and maintain databases. Because of the nature of the systems, computer programmers were generally the people who used the DBMS. If a business needed to access specific types of information from a database (e.g., monthly income figures by company sector), a programmer had to write a program to access that information. Each piece of information the company needed to access would have to be found using unique programming. This process was often time-consuming and expensive.

Because the process was inefficient, programmers developed query languages, which allowed individuals to make requests to databases. Many of these programs were developed during the 1970s. SQL was one such language and was developed in 1974 by IBM. SQL soon became one of the most popular query languages.

Even though SQL made querying databases more efficient, it did not replace the need for computer programming when locating information in databases. Programmers still develop programs to generate reports and compile important data. Often, these programs use SQL. The programmers can use SQL in the programs in one of three ways: through embedded SQL, through SQL modules, and through call-level interface (CLI). The most popular way to use SQL in programs is embedded SQL, meaning that SQL statements are incorporated into another language (such as C or COBOL) used by the programmer. SQL modules are made up of groups of procedures, with each procedure containing one single SQL command. CLIs are functions that send messages to the DBMS and receive information from the DBMS.

How SQL Works

A query is a single request made to a database. SQL helps people make these requests to the database. SQL is made up of about sixty commands, all of which make different requests to databases. Although SQL has many different commands that help it perform a number of functions, it is not a complete language. That means that it cannot create entire programs. Instead, it has specific functions that it can perform in already existing programs. That is why many SQL requests are embedded in another host language.

The DBMS is the system that actually processes a query sent by SQL. When SQL sends a query, the DBMS first parses the statement. That means that the DBMS breaks down the request into smaller parts and determines exactly what the query is asking. The DBMS usually identifies any misspellings or language errors during the parsing step. Next, the DBMS compares the information in the query with the information in the database to make sure the information being requested exists. This step is called validation. After validation, the DBMS creates a plan to access the information requested by the query. Then the DBMS optimizes the plan to ensure it is using the most efficient process to access the information. Although this optimization step can take some time to complete, it is very important. Some queries search for multiple pieces of data in multiple tables, and finding the most efficient way to do the search will save time in the end. Finally, the DBMS executes the plan and gathers the requested information. Although this is the general process that a DBMS uses to execute a SQL query, some systems do the steps in different orders or take different amounts of time to complete each step.

SQL commands are the part of the language that explains what a query is supposed to do or find. Four of the most basic SQL commands are DELETE (to delete existing data), SELECT (to request existing data), UPDATE (to change existing data), and INSERT (to insert new data). Four different types of SQL commands exist: data definition language (DDL), data manipulation language (DML), data control language (DCL), and transactional language. DDL commands are used to create or change database structures and can include CREATE and ALTER. DML commands are used to change or select data inside a database and can include INSERT and DELETE. DCL commands control which users can access information and include GRANT and REVOKE. Transactional language commands control logical units of work and include COMMIT and SAVEPOINT.

SQL and NoSQL Databases

For decades, SQL was the standard language for building and working with databases. In the twenty-first century, however, NoSQL databases also gained popularity. NoSQL software allows people to create databases with more flexibility and more options. Because of this, NoSQL has become a prominent force in database creation. Part of NoSQL's increase in popularity was due to the emergence of big data; as more companies are relying on big data, more of them are turning to NoSQL systems because of the systems' flexibility. However, NoSQL can have problems working with SQL technology. As a result, some businesses still need to use SQL in their database management.

Bibliography

"Foundations of SQL." University of Cincinnati Libraries, guides.libraries.uc.edu/sql. Accessed 9 July 2024.

Mullins, Craig S., et al. "NoSQL (Not Only SQL Database)." TechTarget, Apr. 2021, www.techtarget.com/searchdatamanagement/definition/NoSQL-Not-Only-SQL#guideSection1. Accessed 9 July 2024.

"Processing a SQL Statement." Microsoft: Developer Network, 2 Feb. 2023, msdn.microsoft.com/en-us/library/ms713599(v=vs.85).aspx. Accessed 9 July 2024.

"Structured Query Language (SQL)." Microsoft: Developer Network, 28 Feb. 2023, learn.microsoft.com/en-us/sql/odbc/reference/structured-query-language-sql?view=sql-server-ver16. Accessed 9 July 2024.

Yasar, Kinza, et al. "Structured Query Language (SQL)." TechTarget, Apr. 2024, www.techtarget.com/searchdatamanagement/definition/SQL. Accessed 9 July 2024.