SQL01 - Introduction
SQL01 - Introduction
SQL01 - Introduction
Introduction
Structured Query Language
Sw. Requirements
• Oracle SQLDeveloper
• Connection Data:
• Host: 192.168.1.199
• Port: 1521
• SID: VIS
• User: apps
• Pass: apps
Key Terms
• Data
• Any important information like an employee’s salary.
• Database
• An organized collection of data or information.
• DBMS
• Database Management System
• A Program that stores, retrieves, modifies data in database.
• Relational database
• Collection of two-dimensional tables.
Relational Database Components
How a database is created
Model of
Entity model of
system
client’s model
in client’s
mind
Table model
of entity model Oracle
server
Entity becomes a table
Attribute becomes columns of a table
Tables on disk
ER Diagram
• ER model consists of the various entities in a business and the
relationships among them.
EMPLOYEE assigned to DEPARTMENT
#* number #* number
* name * name
composed of
o job title o location
• Scenario:
• “. . . Assign one or more employees to a
department . . .”
• “. . . Some departments do not yet have assigned employees….”
Relating Multiple Tables
• Each row of data in a table is uniquely identified by a primary key.
• You can logically relate data from multiple tables using foreign keys.
Table name: DEPARTMENTS
…
Primary key Foreign key Primary key
Relational Database Terminology
3
2 4
1
Using SQL to Query Your Database
• Structured query language (SQL) is:
• The ANSI standard language for operating relational databases
• Efficient, easy to learn, and use
• Functionally complete (With SQL, you can define, retrieve, and manipulate
data in the tables.)
SELECT department_name
FROM departments;
Oracle
server
Create Read Update Delete
Create: Update:
insert into xxx_temp update xxx_temp
values (2, 'Test 2'); set id = 4
where id < 10
Read:
select id, text Delete:
from xxx_temp delete from xxx_temp
where id < 10 where id < 10
SQL Statements
SELECT Data manipulation language
(DML)
INSERT
UPDATE
DELETE
JOB_HISTORY
employee_id
start_date EMPLOYEES
end_date employee_id COUNTRIES
job_id first_name country_id
department_id last_name country_name
email region_id
phone_number
hire_date
job_id
salary
JOBS commission_pct
job_id manager_id
job_title department_id REGIONS
min_salary region_id
max_salary region_name
Key Points For SQL Statements
• SQL statements are not case-sensitive. The data entered is case
sensitive.
• SQL statements can be entered on one or many lines.
• Keywords cannot be split across lines or abbreviated.
• Clauses are usually placed on separate lines for readability and ease
of editing.
• Indents should be used to make code more readable.
• Keywords typically are entered in uppercase; all other words, such as
table names and columns names are entered in lowercase.
Key Points For SQL Statements
• Null is a value that is unavailable, unassigned, unknown, or
inapplicable. Null is not the same as zero or a blank space. Zero is a
number and blank space is a character.
• A literal is a character, a number, or a date that is included in the
SELECT statement.
• Date and character literal values must be enclosed within single
quotation marks.