Unit 3: Structured Query Language (SQL)
Unit 3
Structured Query Language (SQL)
Introduction
Structured Query Language (SQL) is a database language designed for managing
data held in a relational database management system. SQL was initially developed
by IBM in the early 1970s (Date 1986). The initial version, called SEQUEL (Structured
English Query Language), was designed to manipulate and retrieve data stored in
IBM’s quasi-relational database management system, System R. Then in the late
1970s, Relational Software Inc., which is now Oracle Corporation, introduced the first
commercially available implementation of SQL, Oracle V2 for VAX computers.
Today, data is the basis of any business. The world of enterprise computing is the
epitome of data-driven businesses. The importance of structured storage of data is
unquestionably in the focus. And at this time, with the computing model quickly shifting
towards the cloud, and storage costs falling rapidly, enterprises are leveraging data
more and more to tune their businesses.
It is, then, imperative that a ground-zero understanding of this structured model of
storage and retrieval of data is of paramount importance. A beginner, however,
naturally feels lost in the sea of information available out in the wild world. This series,
Introduction to SQL, comes to the rescue, by starting at the very base of SQL — the
very fabric — and then, launching from there, towards the bigger picture.
MySQL is an SQL (Structured Query Language) based relational database
management system (DBMS). MySQL is compatible with standard SQL and is
frequently used by PHP and Perl. Commercial version of MySQL is also provided
(including technical support)
MySQL is a very popular, open source database. Officially pronounced “my Ess
Que Ell” (not my sequel). Handles very large databases; very fast performance.
▪ Why are we using MySQL?
o Free (much cheaper than Oracle!)
o Each student can install MySQL locally.
o Easy to use Shell for creating tables, querying tables, etc.
o Easy to use with Java JDBC
Unit Learning Outcomes
At the end of the unit, the students should be able to:
o Relate the History of MySQL/MSSQL Server
o Identify role and importance of SQL in database development
CSU-CICS Carig Campus Prepared by: Esmer C. Baricaua 1
Unit 3: Structured Query Language (SQL)
Topic 1: History of SQL Standard
Time Allotment: 2 hours lecture, 3 hours lab
Learning Objectives
At the end of the unit, the student should be able to:
a. Understand the history of SQL standard.
b. Describe the standards for RDBMS.
Activating Prior Learning
1. Write briefly the history of SQL/MySQL
______________________________________________________________
______________________________________________________________
______________________________________________________________
______________________________________________________________
______________________________________________________________
2. Give at least three application how SQL database in a DBMS, is
used.
a.
b.
c.
Presentation of Content
A brief history of SQL standards
The relational database model was slowly but surely becoming the industry standard in the
late 1980s. The problem was, even though SQL became a commonly recognized database
language, the differences in major vendors' implementations were growing, and some kind of
standard became necessary.
Around 1978, the Committee on Data Systems and Language (CODASYL) commissioned the
development of a network data model as a prototype for any future database implementations.
This continued work started in the early 1970s with the Data Definition Language Committee
(DDLC). By 1982, these efforts culminated in the data definition language (DDL) and data
manipulation language (DML) standards proposal. They became standards four years later
— endorsed by an organization with an improbably long name, the American National
CSU-CICS Carig Campus Prepared by: Esmer C. Baricaua 2
Unit 3: Structured Query Language (SQL)
Standards Institute National Committee on Information Technology Standards H2 Technical
Committee on Database (ANSI NCITS H2 TCD).
Structured Query Language) 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.
SQL offers two main advantages over older read–write APIs such as ISAM or VSAM. Firstly,
it introduced the concept of accessing many records with one single command. Secondly, it
eliminates the need to specify how to reach a record, e.g. with or without an index.
Originally based upon relational algebra and tuple relational calculus, SQL consists of many
types of statements, which may be informally classed as sublanguages, commonly: a data
query language (DQL), a data definition language (DDL), a data control language (DCL), and
a data manipulation language (DML). The scope of SQL includes data query, data
manipulation (insert, update and delete), data definition (schema creation and modification),
and data access control. Although SQL is essentially a declarative language (4GL), it also
includes procedural elements.
SQL was one of the first commercial languages to utilize Edgar F. Codd’s relational model.
The model was described in his influential 1970 paper, "A Relational Model of Data for Large
Shared Data Banks". Despite not entirely adhering to the relational model as described by
Codd, it became the most widely used database language.
SQL became a standard of the American National Standards Institute (ANSI) in 1986, and of
the International Organization for Standardization (ISO) in 1987. Since then the standard has
been revised to include a larger set of features. Despite the existence of standards, most SQL
code requires at least some changes before being ported to different database systems.
SQL was initially developed at IBM by Donald D. Chamberlin and Raymond F.
Boyce after learning about the relational model from Edgar F. Codd in the early 1970s. This
version, initially called SEQUEL (Structured English Query Language), was designed to
manipulate and retrieve data stored in IBM's original quasi-relational database management
system, System R, which a group at IBM San Jose Research Laboratory had developed
during the 1970s.
Chamberlin and Boyce's first attempt of a relational database language was Square,
but it was difficult to use due to subscript notation. After moving to the San Jose Research
Laboratory in 1973, they began work on SEQUEL. The acronym SEQUEL was later changed
to SQL because "SEQUEL" was a trademark of the UK-based Hawker Siddeley Dynamics
Engineering Limited company.
After testing SQL at customer test sites to determine the usefulness and practicality of
the system, IBM began developing commercial products based on their System R prototype
including System/38, SQL/DS, and DB2, which were commercially available in 1979, 1981,
and 1983, respectively.
In the late 1970s, Relational Software, Inc. (now Oracle Corporation) saw the potential
of the concepts described by Codd, Chamberlin, and Boyce, and developed their own SQL-
based RDMS with aspirations of selling it to the U.S. Navy, Central Intelligence Agency, and
other U.S. government agencies. In June 1979, Relational Software, Inc. introduced the first
commercially available implementation of SQL, Oracle V2 (Version2) for VAX computers.
CSU-CICS Carig Campus Prepared by: Esmer C. Baricaua 3
Unit 3: Structured Query Language (SQL)
By 1986, ANSI and ISO standard groups officially adopted the standard "Database
Language SQL" language definition. New versions of the standard were published in 1989,
1992, 1996, 1999, 2003, 2006, 2008, 2011 and, most recently, 2016.
Topic 2: The Role of SQL in Database Architecture
Time Allotment: 2 hours lecture, 3 hours laboratory
Learning Objectives
At the end of this topic, you will be able to:
1. Describe the role of SQL in a database
2. Explain how SQL database works.
Activating Prior Learning
1. Describe briefly databases and SQL Database architecture.
______________________________________________________________
______________________________________________________________
______________________________________________________________
______________________________________________________________
______________________________________________________________
2. What is the role of SQL in database?
______________________________________________________________
______________________________________________________________
______________________________________________________________
______________________________________________________________
Presentation of Content
How SQL Works?
Figure given here shows how SQL works. The client system in the figure has a
database that stores essential information. If business environment, the database
might store production, sales, payroll or inventory data. On a personal computer
system, the database might store personal data, lists of people and their contact
information, or data derived from a bigger computer system.
CSU-CICS Carig Campus Prepared by: Esmer C. Baricaua 4
Unit 3: Structured Query Language (SQL)
The database is controlled by a computer program dubbed a database management
system (DBMS), which is a relational database management system (RDBMS) in case
of the SQL.
When data is to be retrieved from a computer database, the SQL language is used to
transfer the request, which is then processed by the DBMS to invoke the requested
data, and return it to you.
This process of requesting data from a database and receiving results is termed as a
database query - hence the name “Structured Query Language”.
The Role of SQL
SQL is way more than a mere query tool, though retrieving data from a
computer database was SQL’s originally intended purposes and it still is the most
important function for which the database language is employed by almost all leading
IT enterprises.
However, having said that, SQL is extensively employed to control all important
functions a user can perform through a database management system, including:
1. Data definition. SQL allows a database administrator to define the organization
and structure of stored data and the relationships amongst different stored data
items.
2. Data retrieval. SQL helps an application or user program to fetch stored data from
a computer database and make use of it.
3. Data manipulation. SQL helps an application or user program to update the
computer database by removing old data, modifying hitherto stored data, and
adding new data.
CSU-CICS Carig Campus Prepared by: Esmer C. Baricaua 5
Unit 3: Structured Query Language (SQL)
4. Access control. SQL can also be deployed for restricting user permission for
adding, retrieving or modifying stored data, thence protecting data from
unauthorized access.
5. Data sharing. SQL is used by concurrent users to coordinate data sharing to
ensure the users don’t interfere with one another.
6. Data integrity. SQL is also used in a database to define integrity constraints to
prevent data corruption by system failure or inconsistent update.
SQL is, therefore, a comprehensive language and a resourceful, powerful tool to
control and interact with a computer database system.
SQL can’t exactly be termed as a complete language like C, C++, Java, Python or
COBOL. In SQL, there’s no IF statement to test conditions; also it does not have any
FOR, GOTO, or DO statement to control program flow.
SQL is, instead, a database sub-language that comprises of nearly forty statements
specialized to perform database management tasks.
A user can embed these SQL statements in any other complete language like C or
COBOL for extending the compatibility of that language with the database.
As an alternate, a programmer can explicitly sent them to a database system for
processing, by using a CLI (Call Level Interface) from a computer language like C,
C++ or Java.
Finally, SQL isn’t predominantly a structured language, particularly when equated
to extremely structured languages, for example Pascal, Java, or C. SQL statements
instead look like English sentences, completed by "noise words" that essentially add
no meaning to the statement and are used only for making the sentence more
readable.
Moreover, the SQL language has a few inconsistencies, along with some special rules
to avoid the construction of SQL statements that look fairly legal but do not generally
make much sense. Regardless of these widespread inaccuracies in its name, SQL
has surfaced as the standard relational database language. SQL is relatively easy to
learn yet an immensely powerful language at the same time.
SQL is not itself a standalone product or a complete database. You cannot step into
a computer store and ask for "SQL." Instead, SQL is an integral part of a database
management system, a language and a tool to communicate with the DBMS.
SQL is:
• Structured Query Language
• The standard for relational database management systems (RDBMS)
• SQL-92 Standard
Purpose:
o Specify syntax/semantics for data definition and manipulation
o Define data structures
o Enable portability
o Specific minimal (level 1) and complete (level 2) standards
CSU-CICS Carig Campus Prepared by: Esmer C. Baricaua 6
Unit 3: Structured Query Language (SQL)
o Allow for later growth/enhancement to standard
Databases and SQL Server Databases Architecture
SQL Server consists of a set of various components which fulfill data storage
and data analysis needs for enterprise applications. Database architecture: All the
data is stored in databases which is organized into logical components visible to the
end users. It’s only the administrator who needs to actually deal with the physical
storage aspect of the databases, whereas users only deal with database tables.
Every SQL Server instance has primarily 4 system database i.e. master, model,
tempdb and msdb. All other databases are user created databases as per their needs
and requirements.
A single SQL Server instance is capable of handling thousands of users working on
multiple databases.
CSU-CICS Carig Campus Prepared by: Esmer C. Baricaua 7
Unit 3: Structured Query Language (SQL)
References:
1. Jeffrey A. Hoffer, Mary B. Prescott, Fred R. McFadden, Modern Database
Management, 6th edition, 2002
2. https://en.wikipedia.org/wiki/SQL
3. http://etutorials.org/SQL/sql+bible/Part+I+SQL+Basic+Concepts+and+Principl
es/Chapter+1+SQL+and+Relational+Database+Management+Systems+RDB
MS/Brief+History+of+SQL+and+SQL+Standards/
4. https://www.mssqltips.com/sqlservertutorial/9220/sql-server-architecture-overview/
CSU-CICS Carig Campus Prepared by: Esmer C. Baricaua 8