Beruflich Dokumente
Kultur Dokumente
to SQL
LEARNING OUTCOMES
By the end of this topic, you should be able to:
1. Explain the meaning and application of SQL and its importance.
2. Present the basic structure of SQL and transform-oriented language;
and
3. List and answer from queries before building an SQL.
X INTRODUCTION
In the previous course, you learnt that data model relations form the basis of
database technology. Data technology comprises a strong basic structure based on
the relation theory in mathematics. Currently, a simple and user-friendly query
language in commercial applications is high in demand.
This topic will explain what SQL is and the importance of learning the language
in building a current database application.
ACTIVITY 1.1
2 X TOPIC 1 INTRODUCTION TO SQL
SQL is a query language for database. You have learnt that there are many
software applied in a database such as Access, Oracle and others. Is SQL suitable
for all types of database software?
Why do you need a query language? In reality, a structured and systematic query
system is required to minimise errors in interpreting the required space. We also
require a standard system which is applicable to various peripherals and database
systems from different suppliers. This enables users and developers to learn
techniques conforming to most database systems.
SQL was introduced to fulfill the above requirements and it is the most widely
used database language.
In addition, a database language must perform these tasks with minimal user
effort. Its command structure and syntax must be relatively easy to learn and most
importantly the language must be portable, that is, it must conform to some
recognised standard so that the user can use the same command structure and
syntax when moving from one DBMS to another. SQL is intended to satisfy these
requirements.
1. A Data Definition Language (DDL) for defining the database structure and
controlling access to data; and
2. A Data Manipulation Language (DML) for retrieving and updating data.
Information on SQL may be obtained from many books. Among those that can
enrich your knowledge is Database System; Principles, Design and
Implementation written by Catherine Ricardo, published by New York McMillan,
1990.
Before you proceed, attempt the following questions based on the basic concepts
you have just learnt.
SELF-CHECK 1.1
2. What are the two main components of SQL and state the function
of each component?
The history of the relational model started with the publication of the seminal
paper by E.F. Codd in 1970 while he was with IBM. At that point in time,
"Structured English Query Language (SEQUEL) was introduced as an upgraded
4 X TOPIC 1 INTRODUCTION TO SQL
version of SEQUEL. A revised version, SEQUEL/2, was defined in 1976, but the
name was subsequently changed to SQL for legal reasons as SEQUEL was used
by other parties. SQL was then introduced in a DBMS command by the company
ORACLE.
You know that SQL is a structured language; can you think of why it
is referred to as structured?
Each query in the SQL language consists of three basic clauses in the following
format
TOPIC 1 INTRODUCTION TO SQL W 5
1. SQL statements are words defined by SQL and words defined by users.
Words defined by SQL are known as reserved words with unchangeable
meaning. Words defined by users are normally for tables, column, views
and situations. All these must adhere to the fixed syntax.
(i) Upper case letters are used to represent reserved words and lower case
letters are used to represent users-defined words.
(v) Literals must be typed as stores in the database. Literals are constants
in SQL statements. All literals must be enclosed in single quotes, for
example "Database", unless it is numeric.
Although SQL is a free format for standardising and easy reading we shall follow
the following formats:
X operator Y
Operator Meaning
= equals to
< less than
> more than
<= less or equals to
>= more or equals to
<> not equal to
The following exercise will assist you in better understanding the topic you have
just learnt.
TOPIC 1 INTRODUCTION TO SQL W 7
SELF-CHECK 1.2
Once you have learnt the basic SQL structure, let us rest our mind before
proceeding to the next section.
You must remember these four questions without thinking of the SQL structure.
In creating an SQL, develop a habit of answering questions. You may be able to
answer simple questions automatically but for complex questions, you may need
to answer the question part by part. Proceed to the other questions until you are
able to comprehend each question as a whole.
You can also command a system to calculate arithmetic equations such as average
amount, plus, minus, multiply and divide.
ACTIVITY 1.1
SELF-CHECK 1.3
You have learnt what an SQL statement is and the importance of learning this
language. Two components involved in the SQL language are the Data Definition
Language and Data Manipulation Language. These languages are important in
enabling us to identify and update a database.
Before any queries in the SQL language are developed, we have to ask four (4)
important questions:
What is the output required?
What have you learnt? What are the restrictions?
What are the tables involved?
How are the tables linked?
10 X TOPIC 1 INTRODUCTION TO SQL
By answering all the questions involved, you will be able to construct the SQL
query language. It is hoped that you will be able to comprehend a higher level of
SQL language in the next topic.