Hyrje
Hyrje
Hyrje
Introduction
Relational and Object Relational
Database Management Systems
• Relational model and object relational model
• User-defined data types and objects
• Fully compatible with relational database
• Supports multimedia and large objects
• High-quality database server features
I-2
Data Storage on Different Media
Electronic
Filing cabinet Database
spreadsheet
I-3
Relational Database Concept
I-4
Definition of a Relational Database
Oracle
server
… …
I-5
Data Models
Model of
Entity model of
system
client’s model
in client’s
mind
Table model
of entity model Oracle
server
Tables on disk
I-6
Entity Relationship Model
EMPLOYEE DEPARTMENT
assigned to
#* number #* number
* name * name
o job title composed of o location
• Scenario:
– “. . . Assign one or more employees to a
department . . .”
– “. . . Some departments do not yet have assigned employees
. . .”
I-7
Entity Relationship
Modeling Conventions
Entity: Attribute:
• Singular, unique name • Singular name
• Uppercase • Lowercase
• Mandatory marked with “*”
• Soft box • Optional marked with “o”
• Synonym in parentheses
EMPLOYEE DEPARTMENT
#* number assigned to
#* number
* name * name
o job title composed of o location
I-8
Relating Multiple Tables
…
Primary key Foreign key Primary key
I-9
Relational Database Terminology
3
2 4
I - 10
Architecture
I - 11
Logical & Physical Structure
I - 12
Logical & Physical Structure
I - 13
Using SQL to Query Your Database
I - 14
SQL Statements
SELECT
INSERT
UPDATE Data manipulation language (DML)
DELETE
MERGE
CREATE
ALTER
DROP Data definition language (DDL)
RENAME
TRUNCATE
COMMENT
COMMIT
ROLLBACK Transaction control
SAVEPOINT
I - 15
Development Environments for SQL
In this course:
• Primarily use Oracle SQL Developer
• Use SQL*Plus:
– In case you do not have access to Oracle SQL Developer
– Or when any command does not work in Oracle SQL
Developer
I - 16
What Is Oracle SQL Developer?
SQL Developer
I - 17
Specifications of Oracle SQL Developer
• Developed in Java
• Supports Windows, Linux, and Mac OS X platforms
• Default connectivity by using the JDBC Thin driver
• Does not require an installer
– Unzip the downloaded Oracle SQL Developer kit and double-
click sqldeveloper.exe to start Oracle SQL Developer.
• Connects to any Oracle Database, version 9.2.0.1 and later
• Freely downloadable from the following link:
– http://www.oracle.com/technology/products/database/
sql_developer/index.html
• Needs JDK 1.5 installed on your system, which can be
downloaded from the following link:
– http://java.sun.com/javase/downloads/index_jdk5.jsp
I - 18
Oracle SQL Developer Interface
I - 19
Creating a Database Connection
I - 20
Creating a Database Connection
1
I - 21
Browsing Database Objects
I - 22
Using the SQL Worksheet
Enter SQL
Statements.
Results are
shown here.
I - 23
Using the SQL Worksheet
1 2 4 6 8 9
5 7
3
I - 24
Executing SQL Statements
F9 F5
F5
F9
I - 25
Formatting the SQL Code
Before
formatting
After
formatting
I - 26
Saving SQL Statements
2
3
I - 27
Running Script Files
I - 28
Starting SQL*Plus from Oracle SQL Developer
Provide the
location of the
sqlplus.exe
file only for
the first time
you invoke
SQL*Plus.
I - 29
SQL Statements in SQL*Plus
I - 30
The Human Resources (HR)Schema
DEPARTMENTS LOCATIONS
department_id location_id
department_name street_address
manager_id postal_code
location_id city
state_province
country_id
JOB_HISTORY
employee_id
start_date EMPLOYEES
employee_id
end_date
first_name
job_id
last_name COUNTRIES
department_id
email country_id
phone_number country_name
hire_date region_id
job_id
salary
commission_pct
JOBS manager_id
job_id department_id
job_title
min_salary
REGIONS
max_salary region_id
region_name
I - 31
Tables Used in the Course
EMPLOYEES
DEPARTMENTS JOB_GRADES
I - 32