Вы находитесь на странице: 1из 30

I

Introduction

Copyright Oracle Corporation, 1998. All rights reserved.

Objectives
After completing this lesson, you should be able to do the following: Discuss the theoretical and physical aspects of a relational database Describe the Oracle implementation of the RDBMS and ORDBMS Describe how SQL and PL/SQL are used in the Oracle product set Describe the use and benefits of PL/SQL
I-2
Copyright Oracle Corporation, 1998. All rights reserved.

System Development Life Cycle


Strategy and Analysis

Design Build and Document


Transition Production

I-3

Copyright Oracle Corporation, 1998. All rights reserved.

Data Storage on Different Media


SALGRADE
GRADE LOSAL HISAL --------- --------- --------DEPT 1 700 1200 DEPTNO DNAME LOC 2 1201 1400 --------- -------------- ---------3 1401 2000 10 ACCOUNTING NEW YORK 4 2001 3000 20 RESEARCH DALLAS 5 3001 9999 30 SALES CHICAGO 40 OPERATIONS BOSTON

Database Electronic spreadsheet


I-5

Filing cabinet
Copyright Oracle Corporation, 1998. All rights reserved.

Relational Database Concept


Dr. E. F. Codd proposed the relational model for database systems in 1970.

It is the basis for the relational database management system (RDBMS).


The relational model consists of the following:
Collection of objects or relations
Set of operators to act on the relations Data integrity for accuracy and consistency

I-6

Copyright Oracle Corporation, 1998. All rights reserved.

Relational Database Definition


A relational database is a collection of relations or two-dimensional tables.
Database

Table Name: EMP


EMPNO DEPTNO 7839 10 ENAME KING JOB PRESIDENT

Table Name: DEPT


DEPTNO 10 20 30 DNAME ACCOUNTING RESEARCH SALES LOC NEW YORK DALLAS CHICAGO

7698 7782 10 7566 I-7

BLAKE CLARK
JONES

MANAGER MANAGER

30

40

OPERATIONS

BOSTON

MANAGER 20 Copyright Oracle Corporation, 1998. All rights reserved.

Data Models

Model of system in clients mind

Entity model of clients model Table model of entity model

Server

Tables on disk
I-8
Copyright Oracle Corporation, 1998. All rights reserved.

Entity Relationship Model


Create an entity relationship diagram from business specifications or narratives
EMPLOYEE #* number * name o job title DEPARTMENT #* number * name composed of o location

assigned to

Scenario . . . Assign one or more employees to a department . . . . . . Some departments do not yet have assigned employees . . .
I-9
Copyright Oracle Corporation, 1998. All rights reserved.

Entity Relationship Modeling Conventions


Entity Soft box Singular, unique name Uppercase Synonym in parentheses Attribute Singular name Lowercase Mandatory marked with * Optional marked with o

EMPLOYEE #* number * name o job title

assigned to
composed of

DEPARTMENT #* number * name o location

Unique Identifier (UID) Primary marked with # Secondary marked with (#)
I-10
Copyright Oracle Corporation, 1998. All rights reserved.

Entity Relationship Modeling Conventions


Entity Soft box Singular, unique name Uppercase Synonym in parentheses Attribute Singular name Lowercase Mandatory marked with * Optional marked with o

EMPLOYEE #* number * name o job title

assigned to

DEPARTMENT #* number * name composed of o location

Unique Identifier (UID) Primary marked with # Secondary marked with (#)
I-11
Copyright Oracle Corporation, 1998. All rights reserved.

Relational Database Terminology


2
EMPNO ENAME JOB

3
MGR HIREDATE SAL

4
COMM DEPTNO ----------10 30 10 20 1400 300 30 30 30 30 500 30 20 20

------------- ------------ --------------------- -------- ---------------- ----------- -------------7839 KING 7698 BLAKE 7782 CLARK 7566 JONES 7654 MARTIN 7499 ALLEN PRESIDENT MANAGER MANAGER MANAGER SALESMAN SALESMAN 7839 7839 7839 7698 7698 7698 7698 7698 7566 7902 17-NOV-81 01-MAY-81 09-JUN-81 02-APR-81 28-SEP-81 20-FEB-81 08-SEP-81 03-DEC-81 22-FEB-81 03-DEC-81 17-DEC-80 5000 2850 2450 2975 1250 1600 1500 950 1250 3000 800

7844 TURNER SALESMAN 7900 JAMES 7521 WARD 7902 FORD 7369 SMITH CLERK SALESMAN ANALYST CLERK

7788
7876

SCOTT
ADAMS MILLER

ANALYST
CLERK CLERK

7566
7788 7782

09-DEC-82
12-JAN-83 23-JAN-82

3000
1100 1300

20
20 10

1
I-12

7934

Copyright Oracle Corporation, 1998. All rights reserved.

Relating Multiple Tables


Each row of data in a table is uniquely identified by a primary key (PK).

You can logically relate data from multiple tables using foreign keys (FK).
Table Name: EMP
EMPNO DEPTNO 7839 10 7698 ENAME KING BLAKE JOB PRESIDENT MANAGER 30

Table Name: DEPT


DEPTNO 10 20 30 40 DNAME ACCOUNTING RESEARCH SALES OPERATIONS LOC NEW YORK DALLAS CHICAGO BOSTON

7782 10 7566

CLARK
JONES

MANAGER
MANAGER 20

Primary key
I-13

Foreign key

Primary key

Copyright Oracle Corporation, 1998. All rights reserved.

Relational Database Properties


A relational database Can be accessed and modified by executing structured query language (SQL) statements Contains a collection of tables with no physical pointers Uses a set of operators

I-14

Copyright Oracle Corporation, 1998. All rights reserved.

Communicating with a RDBMS Using SQL


SQL statement is entered
SQL> SELECT loc 2 FROM dept;

Statement is sent to database

Database

Data is displayed
LOC ------------NEW YORK DALLAS CHICAGO BOSTON

I-15

Copyright Oracle Corporation, 1998. All rights reserved.

Relational Database Management System


Server

User tables
I-16
Copyright Oracle Corporation, 1998. All rights reserved.

Data dictionary

Oracle8: Object Relational Database Management System


User-defined data types and objects

Fully relational compatible


Support of multimedia and large objects High-quality database server features

I-17

Copyright Oracle Corporation, 1998. All rights reserved.

Defining an Object
An object

Is a person, place, or thing


Knows things about itself and performs actions Has an identity

I am a clock. I know my time zone, and I can display time.


I-18
Copyright Oracle Corporation, 1998. All rights reserved.

Using an Object Model


Objects model a problem to solve. The model is stated in terms of the interactions between objects. Object models closely resemble the real world.
Buy
Sell

Customers
I-19

Business

Copyright Oracle Corporation, 1998. All rights reserved.

Characteristics of Object systems


Present information in object form Classify objects into object types

Inherit attributes and code


Hide data, code, and attributes Interact with other objects Recognize different objects without analysis Interpret the same command in different ways
I-20
Copyright Oracle Corporation, 1998. All rights reserved.

Oracle Complete Solution


Applications HR Financials Manufacturing ...
Developer 2000 Discoverer Designer 2000

SQL

PL/SQL

SQL* Plus

Oracle7/8

Database

Data dictionary Data tables

I-21

Copyright Oracle Corporation, 1998. All rights reserved.

SQL Statements
SELECT INSERT UPDATE DELETE CREATE ALTER DROP RENAME TRUNCATE COMMIT ROLLBACK SAVEPOINT GRANT REVOKE
I-22

Data retrieval

Data manipulation language (DML)

Data definition language (DDL)

Transaction control

Data control language (DCL)

Copyright Oracle Corporation, 1998. All rights reserved.

About PL/SQL
PL/SQL is an extension to SQL with design features of programming languages. Data manipulation and query statements of SQL are included within procedural units of code.

I-23

Copyright Oracle Corporation, 1998. All rights reserved.

PL/SQL Environment
PL/SQL engine PL/SQL block PL/SQL block PL/SQL SQL Procedural Statement Executor

SQL Statement Executor Oracle Server

I-24

Copyright Oracle Corporation, 1998. All rights reserved.

Benefits of PL/SQL
Integration

Application

Shared library
I-25
Copyright Oracle Corporation, 1998. All rights reserved.

Oracle Server

Benefits of PL/SQL
Improve Performance
SQL SQL SQL SQL

Application

Other DBMSs

Application

SQL IF...THEN SQL ELSE SQL END IF; SQL

Oracle with PL/SQL

I-26

Copyright Oracle Corporation, 1998. All rights reserved.

Benefits of PL/SQL
Modularize program development
Anonymous block
Stored procedure/ function Application procedure/ function

DECLARE
Application trigger

BEGIN EXCEPTION

Database trigger

END;

Packaged procedure

I-27

Copyright Oracle Corporation, 1998. All rights reserved.

Benefits of PL/SQL
It is portable. You can declare identifiers. You can program with procedural language control structures. It can handle errors.

I-28

Copyright Oracle Corporation, 1998. All rights reserved.

Benefits of PL/SQL
It is portable. You can declare identifiers. You can program with procedural language control structures. It can handle errors.

I-29

Copyright Oracle Corporation, 1998. All rights reserved.

Tables Used in the Course


EMP
EMPNO --------7839 7698 7782 7566 7654 7499 7844 7900 ENAME ---------KING BLAKE CLARK JONES MARTIN ALLEN TURNER JAMES JOB MGR HIREDATE SAL COMM DEPTNO --------- --------- --------- --------- --------- --------PRESIDENT 17-NOV-81 5000 10 MANAGER 7839 01-MAY-81 2850 30 MANAGER MANAGER SALESMAN SALESMAN SALESMAN CLERK 7839 7839 7698 7698 7698 7698 09-JUN-81 02-APR-81 28-SEP-81 20-FEB-81 08-SEP-81 03-DEC-81 1500 2975 1250 1600 1500 950 10 20 30 30 30 30

1400 300 0

DEPT
DEPTNO --------10 20 30 40

7521 WARD DNAME 7902 FORD -------------7369 SMITH ACCOUNTING 7788 SCOTT RESEARCH 7876 ADAMS SALES 7934 MILLER OPERATIONS

SALESMAN LOC ANALYST ---------CLERK NEW YORK ANALYST DALLAS CLERK CHICAGO CLERK BOSTON

7698 7566 7902 7566 7788 7782

22-FEB-81 03-DEC-81 17-DEC-80 09-DEC-82 12-JAN-83 23-JAN-82

1250 500 30 SALGRADE 3000 20 800 20 GRADE LOSAL HISAL 3000 20 --------- --------- --------1100 1 20 700 1200 1300 2 10 1201 1400 3 1401 2000 4 2001 3000 5 3001 9999

I-30

Copyright Oracle Corporation, 1998. All rights reserved.

Summary
Relational databases are composed of relations, managed by relational operations, and governed by data integrity constraints. Oracle Server allows you to store and manage information by using the SQL language and PL/SQL engine. PL/SQL is an extension to SQL with design features of programming languages.
I-31
Copyright Oracle Corporation, 1998. All rights reserved.

Вам также может понравиться