Les00 Intoduction

24
Copyright Oracle Corporation, 1998 All rights reserved I Introduction

Transcript of Les00 Intoduction

Page 1: Les00 Intoduction

Copyright Oracle Corporation, 1998 All rights reserved

I

Introduction

Page 2: Les00 Intoduction

I-2 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

Page 3: Les00 Intoduction

I-3 Copyright Oracle Corporation, 1998 All rights reserved

System Development Life Cycle

Strategy

and

AnalysisDesign

Build

and

Document

Transition

Production

Page 4: Les00 Intoduction

I-5 Copyright Oracle Corporation, 1998 All rights reserved

Data Storage on Different Media

Electronic

spreadsheetFiling cabinet

Database

SALGRADE

GRADE LOSAL HISAL

--------- --------- ---------

1 700 1200

2 1201 1400

3 1401 2000

4 2001 3000

5 3001 9999

DEPT

DEPTNO DNAME LOC

--------- -------------- ----------

10 ACCOUNTING NEW YORK

20 RESEARCH DALLAS

30 SALES CHICAGO

40 OPERATIONS BOSTON

Page 5: Les00 Intoduction

I-6 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

Page 6: Les00 Intoduction

I-7 Copyright Oracle Corporation, 1998 All rights reserved

Definition of a

Relational DatabaseA relational database is a collection of relations or two-dimensional tables

Database

DEPTNO DNAME LOC

10 ACCOUNTING NEW YORK

20 RESEARCH DALLAS

30 SALES CHICAGO

40 OPERATIONS BOSTON

Table Name DEPT

EMPNO ENAME JOB DEPTNO

7839 KING PRESIDENT 10

7698 BLAKE MANAGER 30

7782 CLARK MANAGER 10

7566 JONES MANAGER 20

Table Name EMP

Page 7: Les00 Intoduction

I-8 Copyright Oracle Corporation, 1998 All rights reserved

Data Models

Model of

system

in client’s

mind

Entity model of

client’s model

Table model

of entity model

Tables on disk

Server

Page 8: Les00 Intoduction

I-9 Copyright Oracle Corporation, 1998 All rights reserved

• Create an entity relationship diagram from business specifications or narratives

• Scenario

– “ Assign one or more employees to a department ”

– “ Some departments do not yet have assigned employees ”

Entity Relationship Model

EMPLOYEE

# number

name

o job title

DEPARTMENT

# number

name

o location

assigned to

composed of

Page 9: Les00 Intoduction

I-10 Copyright Oracle Corporation, 1998 All rights reserved

Entity Relationship

Modeling ConventionsEntity

Soft box

Singular, unique name

Uppercase

Synonym in parentheses

Attribute

Singular name

Lowercase

Mandatory marked with “ ”

Optional marked with “o”

Unique Identifier UID

Primary marked with “#”

Secondary marked with “ # ”

EMPLOYEE

# number

name

o job title

DEPARTMENT

# number

name

o location

assigned to

composed of

Page 10: Les00 Intoduction

I-12 Copyright Oracle Corporation, 1998 All rights reserved

Relational Database Terminology

1

2 3 4

5

EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO

------------- ------------ --------------------- -------- ---------------- ----------- --------------

7839 KING PRESIDENT 17-NOV-81 5000 10

7698 BLAKE MANAGER 7839 01-MAY-81 2850 30

7782 CLARK MANAGER 7839 09-JUN-81 2450 10

7566 JONES MANAGER 7839 02-APR-81 2975 20

7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30

7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30

7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30

7900 JAMES CLERK 7698 03-DEC-81 950 30

7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30

7902 FORD ANALYST 7566 03-DEC-81 3000 20

7369 SMITH CLERK 7902 17-DEC-80 800 20

7788 SCOTT ANALYST 7566 09-DEC-82 3000 20

7876 ADAMS CLERK 7788 12-JAN-83 1100 20

7934 MILLER CLERK 7782 23-JAN-82 1300 10

6

Page 11: Les00 Intoduction

I-13 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

Table Name EMP Table Name DEPT

Primary key Primary key

• You can logically relate data from multiple tables using foreign keys FK

Foreign key

EMPNO ENAME JOB DEPTNO

7839 KING PRESIDENT 10

7698 BLAKE MANAGER 30

7782 CLARK MANAGER 10

7566 JONES MANAGER 20

DEPTNO DNAME LOC

10 ACCOUNTING NEW YORK

20 RESEARCH DALLAS

30 SALES CHICAGO

40 OPERATIONS BOSTON

Page 12: Les00 Intoduction

I-14 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

Page 13: Les00 Intoduction

I-15 Copyright Oracle Corporation, 1998 All rights reserved

Communicating with a RDBMS

Using SQL

Database

SQL> SELECT loc

2 FROM dept;

SQL statement

is entered Statement is sent to

database

LOC

-------------

NEW YORK

DALLAS

CHICAGO

BOSTON

Data is displayed

Page 14: Les00 Intoduction

I-16 Copyright Oracle Corporation, 1998 All rights reserved

Relational Database

Management System

User tables Data

dictionary

Server

Page 15: Les00 Intoduction

I-17 Copyright Oracle Corporation, 1998 All rights reserved

Oracle8 Object Relational

Database Management System

• User-defined data types and objects

• Fully compatible with relational database

• Support of multimedia and large objects

• High-quality database server features

Page 16: Les00 Intoduction

I-18 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

Page 17: Les00 Intoduction

I-19 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

Customers Business

Buy

Sell

Page 18: Les00 Intoduction

I-20 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

Page 19: Les00 Intoduction

I-21 Copyright Oracle Corporation, 1998 All rights reserved

Oracle Complete Solution

SQL PL SQL

Oracle7/8

Applications

HR

Financials

ManufacturingOracle Designer

Oracle Developer

Data tables

Data

dictionaryDatabase

SQL Plus

Discoverer

Page 20: Les00 Intoduction

I-22 Copyright Oracle Corporation, 1998 All rights reserved

SQL StatementsSELECT

INSERT

UPDATE

DELETE

CREATE

ALTER

DROP

RENAME

TRUNCATE

COMMIT

ROLLBACK

SAVEPOINT

GRANT

REVOKE

Data retrieval

Data manipulation language DML

Data definition language DDL

Transaction control

Data control language DCL

Page 21: Les00 Intoduction

I-23 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

Page 22: Les00 Intoduction

I-24 Copyright Oracle Corporation, 1998 All rights reserved

PL SQL Environment

PL SQL

block

PL SQL engine

Oracle Server

Procedural

Statement

Executor

PL SQL

SQL

SQL Statement Executor

PL SQL

block

Page 23: Les00 Intoduction

I-25 Copyright Oracle Corporation, 1998 All rights reserved

Tables Used in the Course

EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO

--------- ---------- --------- --------- --------- --------- --------- ---------

7839 KING PRESIDENT 17-NOV-81 5000 10

7698 BLAKE MANAGER 7839 01-MAY-81 2850 30

7782 CLARK MANAGER 7839 09-JUN-81 2450 10

7566 JONES MANAGER 7839 02-APR-81 2975 20

7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30

7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30

7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30

7900 JAMES CLERK 7698 03-DEC-81 950 30

7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30

7902 FORD ANALYST 7566 03-DEC-81 3000 20

7369 SMITH CLERK 7902 17-DEC-80 800 20

7788 SCOTT ANALYST 7566 09-DEC-82 3000 20

7876 ADAMS CLERK 7788 12-JAN-83 1100 20

7934 MILLER CLERK 7782 23-JAN-82 1300 10

EMP

DEPT

DEPTNO DNAME LOC

--------- -------------- ----------

10 ACCOUNTING NEW YORK

20 RESEARCH DALLAS

30 SALES CHICAGO

40 OPERATIONS BOSTON

GRADE LOSAL HISAL

--------- --------- ---------

1 700 1200

2 1201 1400

3 1401 2000

4 2001 3000

5 3001 9999

SALGRADE

Page 24: Les00 Intoduction

I-26 Copyright Oracle Corporation, 1998 All rights reserved

Summary

• Relational databases are composed of relations, managed by relational operations, and governed by data integrity constraints

• The 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