Beruflich Dokumente
Kultur Dokumente
Language
Part I
AC 505
SQL: Outline
Introduction to SQL
Queries in SQL
Update Statements in SQL
Data Definition in SQL
Views in SQL
Embedded SQL
2
Introduction to SQL:
Outline
What is SQL?
Objectives of SQL
History of SQL
Components of SQL
Writing SQL Commands
3
Introduction to SQL:
Outline
What is SQL?
Objectives of SQL
History of SQL
Components of SQL
Writing SQL Commands
4
What is SQL?
Structured Query Language
Transform-oriented language
Non-procedural language
Essentially free-format
Standard English
Introduction to SQL:
Outline
What is SQL?
Objectives of SQL
History of SQL
Components of SQL
Writing SQL Commands
6
Objectives of SQL
To allow a user to create the database
and relation structures.
To allow a user to perform basic data
management tasks.
To allow a user to perform both simple
and complex queries to transform raw
data into information.
7
Objectives of SQL
To perform data management tasks
with minimal effort such that the
command structure and syntax must be
easy to learn.
To be portable.
Introduction to SQL:
Outline
What is SQL?
Objectives of SQL
History of SQL
Components of SQL
Writing SQL Commands
9
SQL History
Originally Structured English Query
Language or SEQUEL, developed by IBM
around 1975.
In 1986, Official American National
Standardization Institute (ANSI) defined an
SQL standard
In 1987, International Organization for
Standardization (ISO) adopted the
standard - informally known as SQL/86.
10
SQL History
In 1989, and again in 1992 , ISO
produced SQL/92 or SQL/2, officially
named International Standard
Database Language SQL (1992)
By 1992, over 100 DBMS products
supported SQL features.
11
Introduction to SQL:
Outline
What is SQL?
Objectives of SQL
History of SQL
Components of SQL
Writing SQL Commands
12
SQL Components
Data Definition Language (DDL)
Data Manipulation Language (DML)
Defining and Maintaining Integrity
Maintaining Security
13
Introduction to SQL:
Outline
What is SQL?
Objectives of SQL
History of SQL
Components of SQL
Writing SQL Commands
14
SQL Notation
An SQL statement consists of:
reserved words
user-defined words
Readable SQL
Each clause should begin on a new line.
The beginning of a clause should line up
with the beginning of other clauses.
If a clause has several parts, they
should each appear on a separate line
and be indented under the start of the
clause to show the relationship.
16
Data Manipulation
SELECT
INSERT
UPDATE
DELETE
19
Data Definition
CREATE TABLE
ALTER TABLE
DROP TABLE
20
SQL: Outline
Introduction to SQL
Queries in SQL
Update Statements in SQL
Data Definition in SQL
Views in SQL
Embedded SQL
21
COMPANY DATABASE
EMPLOYEE(ENo, Name, Address, Sex,
CivilStatus, BDate, Position, SuperENo, DNo)
DEPARTMENT(DNumber,DName,MgrENo)
DEPT_LOCATION(DNo, Location)
PROJECT(PNo, PName, PLocation,DNum)
WORKS_ON(ENo, PNo, Hours)
DEPENDENT(ENo, DependentName, Sex, Bdate,
Relationship)
POSITION(Position, Salary)
22
Queries: Outline
Simple or basic queries
Sorting results
Aggregate functions
Grouping results
Subqueries
Multi-table queries
Combining result tables
23
Queries: Outline
Simple or basic queries
Sorting results
Aggregate functions
Grouping results
Subqueries
Multi-table queries
Combining result tables
24
SELECT Statement:
Objective
To retrieve data from one or more
database tables.
25
SELECT Statement:
Format
SELECT [DISTINCT|ALL] { * |
[column_exp [AS new_name]
[,] ]}
FROM table_name [alias] [,]
[WHERE condition]
[GROUP BY column_list]
[HAVING condition]
[ORDER By column_list];
26
Sequence of
Processing a Select
Statement
FROM
WHERE
GROUP BY
27
Sequence of
Processing a Select
Statement
HAVING
SELECT
ORDER BY
[,] }
SELECT CLAUSE
SELECT [DISTINCT|ALL] { * |
[column_exp [AS new_name]
[,] }
Specifies which columns are to appear in
the output.
DISTINCT is used to eliminate duplicates.
Asterisk * expresses all columns.
column_exp represents a column name or
expression
30
FROM CLAUSE
FROM table_name [alias] [,]
Specifies the table or tables to be used.
table_name is the name of an existing
database table
alias is an optional abbreviation for
table_name
31
Simple Queries
Retrieve all columns, all rows
Retrieve specific columns, all rows
Use of Distinct
Calculated fields
Simple comparison search condition
Compound comparison search condition
Range search condition
Set membership search condition
Pattern match search condition
Null search condition
32
Simple Queries
Retrieve all columns, all rows
Retrieve specific columns, all rows
Use of Distinct
Calculated fields
Simple comparison search condition
Compound comparison search condition
Range search condition
Set membership search condition
Pattern match search condition
Null search condition
33
34
35
Name
Address
Sex
CivilStatus
BDate
Position
SuperENo
DNo
emp01
Manila
male
married
01/01/50
manager
emp02
Maria Clara
Pasay
female
single
01/02/70
secretary
emp01
dept01
emp03
Crisostomo Ibarra
Makati
male
single
01/03/60
assistant manager
emp01
dept01
emp04
Sisa
Quezon City
female
married
02/02/55
staff assistant 1
emp01
dept01
emp05
Elias
Quezon City
male
married
03/03/55
staff assistant 2
emp01
dept01
emp06
Basilio
Mandaluyong
male
single
04/04/55
staff assistant 1
emp01
dept01
emp07
Crispin
Caloocan
male
single
02/02/72
clerk 1
emp01
dept01
emp08
Tasio
Manila
male
divorced
07/02/55
clerk 2
emp01
dept01
emp09
Damaso
Bulacan
male
separated
08/02/62
clerk 3
emp01
dept01
emp10
Simon
San Juan
male
married
12/02/55
staff assistant 2
emp01
dept01
dept01
36
Name
Address
Sex
CivilStatus
BDate
Position
SuperENo
DNo
emp11
Jose Rizal
Manila
male
married
28/10/40
manager
emp12
Gabriela Silang
Pasay
female
single
01/02/70
secretary
emp11
dept02
emp13
Andres Bonifacio
Manila
male
divorced
01/04/63
assistant manager
emp11
dept02
emp14
Tandang Sora
Pasig
female
separated
02/05/58
staff assistant 1
emp11
dept02
emp15
Juan Luna
Manila
male
married
03/03/55
staff assistant 2
emp11
dept02
emp16
Antonio Luna
San Juan
male
single
04/04/55
staff assistant 1
emp11
dept02
emp17
Apolinario Mabini
Pasig
male
single
02/02/72
clerk 1
emp11
dept02
emp18
Emilio Jacinto
Manila
male
single
03/05/58
clerk 2
emp11
dept02
emp19
Ninoy Aquino
Manila
male
married
20/12/66
clerk 3
emp11
dept02
emp20
Quezon City
male
married
11/12/55
staff assistant 2
emp11
dept02
emp21
Evelio Javier
Manila
male
single
30/09/62
clerk 3
emp11
dept02
dept02
37
Name
Address
Sex
CivilStatus
BDate
Position
SuperENo
DNo
emp31
Corazon Aquino
Manila
female
married
05/08/50
manager
emp32
Fidel Ramos
Pasay
male
single
15/08/72
secretary
emp31
dept03
emp33
Joseph Estrada
Manila
male
divorced
06/06/64
assistant manager
emp31
dept03
emp34
Ferdinand Marcos
Pasig
male
separated
28/05/59
staff assistant 1
emp31
dept03
emp35
Diosdado Macapagal
Manila
male
married
15/10/58
staff assistant 2
emp31
dept03
emp36
Ramon Magsaysay
San Juan
male
single
04/04/60
staff assistant 1
emp31
dept03
emp37
Elpidio Quirino
Pasig
male
single
02/07/75
clerk 1
emp31
dept03
emp38
Manuel Quezon
Manila
male
single
01/06/58
clerk 2
emp31
dept03
emp39
Manuel Roxas
Manila
male
married
20/03/68
clerk 3
emp31
dept03
emp40
Emilio Aguinaldo
Quezon City
male
separated
11/12/59
staff assistant 2
emp31
dept03
emp41
Carlos Garcia
Manila
male
single
30/01/64
clerk 3
emp31
dept03
emp42
Sergio Osmena
Manila
male
divorced
31/03/65
clerk 2
emp31
dept03
emp43
Jose Laurel
Manila
male
married
20/06/66
clerk 1
emp31
dept03
dept03
38
Name
Address
Sex
CivilStatus
BDate
Position
SuperENo
DNo
emp51
Ping Lacson
Manila
male
single
01/06/48
manager
emp52
Gloria Arroyo
Mandaluyong
female
single
15/07/62
secretary
emp51
dept04
emp53
Alfredo Lim
Pasig
male
divorced
06/08/63
assistant manager
emp51
dept04
emp54
Miriam Santiago
Pasig
male
separated
29/07/56
staff assistant 1
emp51
dept04
emp55
Lauren Legarda
Manila
female
married
18/10/61
staff assistant 2
emp51
dept04
emp56
Nikki Coseteng
Manila
female
single
04/04/64
staff assistant 1
emp51
dept04
emp57
Nur Misuari
Jolo
male
married
02/08/75
clerk 1
emp51
dept04
emp58
Commander Robot
Sulu
male
single
06/05/57
clerk 2
emp51
dept04
emp59
Joma Sison
Manila
male
married
25/03/70
clerk 3
emp51
dept04
emp60
Nora Aunor
San Juan
female
separated
15/12/62
staff assistant 2
emp51
dept04
emp61
Vilma Santos
Makati
female
single
31/01/68
clerk 3
emp51
dept04
emp62
Sharon Cuneta
Makati
female
divorced
19/04/63
clerk 2
emp51
dept04
emp63
Frank Drilon
Pasay
male
single
20/09/63
clerk 1
emp51
dept04
emp64
Manny Villar
Pasay
male
single
20/05/67
clerk 1
emp51
dept04
dept04
39
40
41
DName
MgrENo
dept01
Noli Me Tangere
emp01
dept02
Heroes
emp11
dept03
Presidents
emp31
dept04
News Makers
emp51
42
PName
Alpha
Beta
Gamma
Theta
Rose
Tulip
Carnation
Red
Blue
Green
Earth
Mars
Venus
Jupiter
Pluto
DNum
dept01
dept01
dept01
dept01
dept02
dept02
dept02
dept03
dept03
dept03
dept04
dept04
dept04
dept04
dept04
PLocation
USA
Europe
Africa
Asia
England
Holland
France
Manila
Davao
Cebu
Europe
Asia
USA
Australia
Latin America
44
Salary
assistant manager
70,000.00
clerk 1
10,000.00
clerk 2
15,000.00
clerk 3
20,000.00
clerk 4
25,000.00
manager
100,000.00
secretary
20,000.00
staff assistant 1
40,000.00
staff assistant 2
50,000.00
staff assistant 3
60,000.00
46
DependentName
Bernadette
Sebastian
Philip
James
Rose
Jude
Peter
John
James
Paul
Martin
Nicholas
Mark
Vincent
Francis
Sex
female
male
male
male
female
male
male
male
male
male
male
male
male
male
male
BDate
1995/01/25
1990/01/05
1990/03/01
1990/06/02
1994/05/26
1995/02/03
1995/04/05
1995/02/20
1990/03/06
1993/01/03
1992/01/07
1996/02/27
1991/08/08
1997/03/28
1998/04/29
Relationship
daughter
son
son
son
daughter
son
son
son
son
son
son
son
son
son
son
48
DependentName
Luke
Angela
Bartolomew
Anne
Timothy
Agatha
Mary
Joaquin
Lucy
Dominic
Valentine
Claire
Therese
Joan
Thomas
Sex
male
female
male
female
male
female
female
male
female
male
male
female
female
female
male
BDate
1992/07/01
1999/05/30
1995/02/10
1994/03/09
1996/06/05
1997/07/06
1993/04/11
1998/05/12
1998/08/07
1997/06/13
1996/09/05
1996/07/14
1995/08/15
1994/09/16
1994/05/17
Relationship
son
daughter
son
daughter
son
daughter
daughter
son
daughter
son
son
daughter
daughter
daughter
son
49
DependentName
Magdalene
Patrick
Joseph
Veronica
Isidore
Lorenzo
George
Pedro
Fidelis
Pio
Ignacia
Margaret
Faustina
Scholastica
Sex
female
male
male
female
male
male
male
male
male
male
female
female
female
female
BDate
1993/06/18
1995/10/08
1994/11/01
1992/07/19
1993/12/02
1991/08/20
1992/01/03
1990/09/21
1991/02/04
1998/10/22
1997/12/23
1992/03/05
1996/11/24
1991/04/06
Relationship
daughter
son
son
daughter
son
son
son
son
son
son
daughter
daughter
daughter
daughter
50
DLocation
Makati
USA
France
Makati
Davao
Makati
Germany
Makati
USA
52
PNo
proj01
proj02
proj03
proj04
proj01
proj02
proj03
proj04
proj01
proj03
proj03
proj04
proj01
proj04
proj01
Hours
2
3
4
5
4
3
2
1
5
6
4
3
4
2
5
54
PNo
proj02
proj03
proj04
proj04
proj01
proj05
proj02
proj05
proj06
proj07
proj05
proj06
proj05
proj06
proj06
Hours
5
5
1
1
1
1
1
6
6
6
3
4
5
6
8
55
PNo
proj07
proj05
proj07
proj05
proj07
proj05
proj06
proj06
proj07
proj05
proj03
proj06
proj07
proj01
proj05
Hours
7
1
1
3
2
4
5
7
6
8
1
1
2
3
3
56
PNo
proj08
proj09
proj10
proj08
proj09
proj08
proj09
proj09
proj10
proj08
proj10
proj08
proj10
proj09
proj10
Hours
5
3
4
4
3
4
5
3
2
5
1
4
6
3
3
57
PNo
proj08
proj10
proj08
proj09
proj10
proj10
proj08
proj07
proj09
proj01
proj02
proj03
proj04
proj05
proj06
Hours
4
3
5
4
4
3
2
1
1
1
1
1
1
1
1
58
PNo
proj07
proj08
proj09
proj10
proj11
proj12
proj13
proj14
proj15
proj11
proj12
proj13
proj14
proj12
proj15
Hours
1
1
1
1
5
6
4
3
3
4
5
4
3
2
1
59
PNo
proj12
proj14
proj11
proj13
proj12
proj14
proj14
proj15
proj11
proj12
proj10
proj14
proj10
proj09
proj15
Hours
5
6
4
3
4
5
3
4
2
1
5
6
4
3
3
60
Simple Queries
Retrieve all columns, all rows
Retrieve specific columns, all rows
Use of Distinct
Calculated fields
Simple comparison search condition
Compound comparison search condition
Range search condition
Set membership search condition
Pattern match search condition
Null search condition
61
Retrieve specific
columns, all rows
A
Table1
B
C
a1
b1
c1
a2
b2
c2
a3
b3
c3
Resulting
Table
SELECT B
FROM Table1;
B
b1
b2
b3
62
Retrieve specific
columns, all rows
Query#08: Produce a list of all projects showing
only the names and locations of projects.
PROJECT(PNo, PName, PLocation,DNum)
SELECT PName, PLocation
FROM PROJECT;
63
PLocation
USA
Europe
Africa
Asia
England
Holland
France
Manila
Davao
Cebu
Europe
Asia
USA
Australia
Latin America
64
Retrieve specific
columns, all rows
Query#09: Produce a list of all department
names
DEPARTMENT(DNumber,DName,MgrEN
o)
SELECT DName
FROM DEPARTMENT;
65
66
Simple Queries
Retrieve all columns, all rows
Retrieve specific columns, all rows
Use of Distinct
Calculated fields
Simple comparison search condition
Compound comparison search condition
Range search condition
Set membership search condition
Pattern match search condition
Null search condition
67
Use of Distinct
A
Table1
B
C
a1
b1
c1
a2
b2
c2
a2
b3
c3
a3
b4
c3
SELECT A
FROM Table1;
SELECT Distinct A
FROM Table1;
RT
RT
a1
a1
a2
a2
a2
a3
a3
68
Use of Distinct
Query#10: Produce a list of all filled-up
positions.
EMPLOYEE(ENo, Name, Address, Sex,
CivilStatus, BDate, Position, SuperENo, DNo)
SELECT DISTINCT Position
FROM EMPLOYEE;
69
70
Position
assistant manager
assistant manager
70,000.00
clerk 1
10,000.00
clerk 2
15,000.00
clerk 3
20,000.00
clerk 3
clerk 4
25,000.00
manager
manager
100,000.00
secretary
secretary
20,000.00
staff assistant 1
40,000.00
staff assistant 2
50,000.00
staff assistant 3
60,000.00
clerk 1
clerk 2
staff assistant 1
staff assistant 2
Salary
71
Use of Distinct
Query#11: Produce a list of all assigned
(employees work on) project numbers.
WORKS_ON(ENo, PNo, Hours)
SELECT DISTINCT PNo
FROM WORKS_ON;
72
73
PNo
proj01
proj02
proj03
proj04
proj05
proj06
proj07
proj08
proj09
proj10
proj11
proj12
proj13
proj14
proj15
PName
Alpha
Beta
Gamma
Theta
Rose
Tulip
Carnation
Red
Blue
Green
Earth
Mars
Venus
Jupiter
Pluto
DNum
dept01
dept01
dept01
dept01
dept02
dept02
dept02
dept03
dept03
dept03
dept04
dept04
dept04
dept04
dept04
PLocation
USA
Europe
Africa
Asia
England
Holland
France
Manila
Davao
Cebu
Europe
Asia
USA
Australia
Latin America
74
Simple Queries
Retrieve all columns, all rows
Retrieve specific columns, all rows
Use of Distinct
Calculated fields
Simple comparison search condition
Compound comparison search condition
Range search condition
Set membership search condition
Pattern match search condition
Null search condition
75
Calculated Fields
An SQL expression can involve:
Addition (+)
Subtraction(-)
Multiplication (*)
Division (/)
Parentheses can be used to build
complex expressions.
76
Calculated Fields
Table1
A B C
SELECT A*10
FROM Table1;
10 b1 c1
20 b2 c2
30 b3 c3
SELECT A*10 As
Product
FROM Table1;
R Table
R Table
Expr01
Product
100
100
200
200
300
300
77
Calculated Fields
Query #12: Produce a list of yearly
salaries of all positions.
POSITION(Position, Salary)
SELECT Position, Salary*12
FROM POSITION;
78
Expr1001
assistant manager
840,000.00
clerk 1
120,000.00
clerk 2
180,000.00
clerk 3
240,000.00
clerk 4
300,000.00
manager
1,200,000.00
secretary
240,000.00
staff assistant 1
480,000.00
staff assistant 2
600,000.00
staff assistant 3
720,000.00
79
Calculated Fields
Query #13: Produce a list of yearly
salaries (AS YearlySalary) of all
positions.
POSITION(Position, Salary)
SELECT Position, Salary*12 AS
YearlySalary
FROM POSITION;
80
YearlySalary
assistant manager
840,000.00
clerk 1
120,000.00
clerk 2
180,000.00
clerk 3
240,000.00
clerk 4
300,000.00
manager
1,200,000.00
secretary
240,000.00
staff assistant 1
480,000.00
staff assistant 2
600,000.00
staff assistant 3
720,000.00
81
Simple Queries
Retrieve all columns, all rows
Retrieve specific columns, all rows
Use of Distinct
Calculated fields
Simple comparison search condition
Compound comparison search condition
Range search condition
Set membership search condition
Pattern match search condition
Null search condition
82
ROW SELECTION
(WHERE clause)
SELECT [DISTINCT|ALL] { * |
[column_exp [AS new_name]
[,] }
FROM table_name [alias] [,]
[WHERE search condition]
83
85
Simple Comparison
Operators
Equals =
Is less than <
Is greater than
>
Is less than or equal to <=
Is greater than or equal to >=
Is not equal to (ISO standard)
<>
Is not equal to (allowed in some) !=
86
RdDb2000
SELECT A, B
FROM Table1
Where A=10;
10 b1 c1
20 b2 c2
30 b3 c3
SELECT A, B
FROM Table1
Where A <>10;
R Table
10 b1
R Table
20 b2
30 b3
87
89
Salary
100,000.00
assistant manager
70,000.00
staff assistant 1
40,000.00
staff assistant 2
50,000.00
staff assistant 3
60,000.00
91
Simple Queries
Retrieve all columns, all rows
Retrieve specific columns, all rows
Use of Distinct
Calculated fields
Simple comparison search condition
Compound comparison search condition
Range search condition
Set membership search condition
Pattern match search condition
Null search condition
92
Logical Operators
AND
OR
NOT
Parentheses ()
93
SELECT A, B
FROM Table1
WHERE A=10 AND
B=b1;
SELECT A, B
FROM Table1
WHERE A <>10 AND
B=b1;
SELECT A, B
FROM Table1
WHERE A <>10 OR
B=b1;
R Table
10 b1
R Table
R Table
10 b1
20 b2
30 b3
95
Position
manager
Jose Rizal
manager
Ping Lacson
manager
97
DLocation
dept01
USA
dept04
USA
dept04
Germany
99
Simple Queries
Retrieve all columns, all rows
Retrieve specific columns, all rows
Use of Distinct
Calculated fields
Simple comparison search condition
Compound comparison search condition
Range search condition
Set membership search condition
Pattern match search condition
Null search condition
100
Range Operators
Attribute BETWEEN x AND y
Attribute NOT BETWEEN x AND y
Attribute >= literal1 AND
Attribute <= literal2
101
SELECT A, B
FROM Table1
WHERE A BETWEEN
10 AND 30;
SELECT A, B
FROM Table1
WHERE A NOT
BETWEEN 10 AND 30;
R Table
R Table
10 b1
20 b2
30 b3
R Table
10 b1
SELECT A, B
FROM Table1
WHERE A >=5 AND A<=15;
102
Salary
secretary
20,000.00
staff assistant 1
40,000.00
clerk 3
20,000.00
clerk 4
25,000.00
105
BDate
1950/01/01
1955/02/02
1955/03/03
1955/04/04
1955/02/07
1955/02/12
1940/10/28
1955/03/03
1955/04/04
1950/08/05
1948/06/01
108
Simple Queries
Retrieve all columns, all rows
Retrieve specific columns, all rows
Use of Distinct
Calculated fields
Simple comparison search condition
Compound comparison search condition
Range search condition
Set membership search condition
Pattern match search condition
Null search condition
109
Set Membership
Operators
Attribute IN ('literal1', 'literal2'
'literaln')
Attribute NOT IN ('literal1', 'literal2'
'literaln')
Note: tests whether a data value
matches one of a list of values; more
efficient than using OR
110
Table1
A B C
10 b1 c1
20 b2 c2
30 b3 c3
SELECT A, B
FROM Table1
WHERE A IN (10,20,30);
SELECT A, B
FROM Table1
WHERE A =10 or A=20 or
A=30;
R Table
R Table
10 b1
20 b2
30 b3
SELECT A, B
FROM Table1
WHERE A NOT IN (10,20,30);
111
Position
Crispin
clerk 1
Tasio
clerk 2
Damaso
clerk 3
clerk 2
Ninoy Aquino
clerk 3
Evelio Javier
clerk 3
Elpidio Quirino
clerk 1
Manuel Quezon
clerk 2
Manuel Roxas
clerk 3
114
Position
Carlos Garcia
clerk 3
Sergio Osmena
clerk 2
Jose Laurel
clerk 1
Nur Misuari
clerk 1
Commander Robot
clerk 2
Joma Sison
clerk 3
Vilma Santos
clerk 3
Sharon Cuneta
clerk 2
Frank Drilon
clerk 1
Manny Villar
clerk 1
115
DLocation
dept02
France
dept03
Davao
117
Simple Queries
Retrieve all columns, all rows
Retrieve specific columns, all rows
Use of Distinct
Calculated fields
Simple comparison search condition
Compound comparison search condition
Range search condition
Set membership search condition
Pattern match search condition
Null search condition
118
(%)
asterisk character represents any
sequence of zero or
more character
(wild card);
? (_)
question mark character represents any
single character.
119
Pattern Matching
Operators
Attribute LIKE H* means the first
character must start with H, but the rest of
the string can be anything.
Attribute LIKE H??? means that there
must be exactly four characters in the
string, the first of which must be an H.
Attribute Like Star#* ESCAPE #
means the use of an escape character to
include * in the string.
120
Pattern Matching
Operators
Table1
A B C
10 b1 c1
20 b2 c2
30 b3 c3
SELECT A, B
FROM Table1
WHERE B LIKE b*;
SELECT A, B
FROM Table1
WHERE B LIKE *4;
SELECT A, B
FROM Table1
WHERE B LIKE *2*;
R Table
R Table
10 b1
20 b2
30 b3
R Table
20 b2
122
124
126
Simple Queries
Retrieve all columns, all rows
Retrieve specific columns, all rows
Use of Distinct
Calculated fields
Simple comparison search condition
Compound comparison search condition
Range search condition
Set membership search condition
Pattern match search condition
Null search condition
129
Null Operators
Attribute IS NULL
Attribute IS NOT NULL
Note:A null is considered to have an
unknown value such that the
attribute cannot be compared to
another string.
130
CENTRAL BANK
DATABASE
Bank (Code, BankName, BankAddress)
Customer (SSN, CName, CAddr, Phone)
Branch (Code, BranchNo, BranchAddress)
Account (AcctNo, BranchNo, Code,
Balance, Type)
Loan (LoanNo, BranchNo, Code,
LoanAmount, Type)
A-C (AccountNo, SSN)
L-C (LoanNo, SSN)
133