Escolar Documentos
Profissional Documentos
Cultura Documentos
Introduction
Objectives
After completing this lesson, you should be After completing this lesson, you should be able to do the following: able to do the following: Discuss the theoretical and physical aspects Discuss the theoretical and physical aspects of a relational database of a relational database Describe the Oracle implementation of the Describe the Oracle implementation of the RDBMS and ORDBMS RDBMS and ORDBMS Describe how SQL and PL/SQL are used in Describe how SQL and PL/SQL are used in the Oracle product set the Oracle product set Describe the use and benefits of PL/SQL Describe the use and benefits of PL/SQL
I-2
I-3
I-4
Filing cabinet
I-6
I-7
Data Models
Server
Tables on disk
I-8
assigned to assigned to
Scenario Scenario . .. .. Assign one or more employees to a . Assign one or more employees to a department .. .. . department . . .. .. Some departments do not yet have . Some departments do not yet have assigned employees .. .. . assigned employees .
I-9
EMPLOYEE EMPLOYEE #* number #* number * name * name o job title o job title
assigned to assigned to
DEPARTMENT DEPARTMENT #* number #* number * name name composed of * composed of o location o location
Unique Identifier (UID) Primary marked with # Secondary marked with (#)
I-10
EMPLOYEE EMPLOYEE #* number #* number * name * name o job title o job title
assigned to assigned to
DEPARTMENT DEPARTMENT #* number #* number * name name composed of * composed of o location o location
Unique Identifier (UID) Primary marked with # Secondary marked with (#)
I-11
3
MGR HIREDATE SAL --------------------- -------- ---------------- ----------- -------------PRESIDENT MANAGER MANAGER MANAGER SALESMAN SALESMAN 7839 7839 7839 7698 7698 7698 7698 7698 7566 7902 7566 7788 7782 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 09-DEC-82 12-JAN-83 23-JAN-82 5000 2850 2450 2975 1250 1600 1500 950 1250 3000 800 3000 1100 1300 500 1400 300
4
COMM DEPTNO ----------10 30 10 20 30 30 30 30 30 20 20 20 20 10
7839 KING 7698 BLAKE 7782 CLARK 7566 JONES 7654 MARTIN 7499 ALLEN
7844 TURNER SALESMAN 7900 JAMES 7521 WARD 7902 FORD 7369 7788 7876 SMITH SCOTT ADAMS MILLER CLERK SALESMAN ANALYST CLERK ANALYST CLERK CLERK
1
I-12
7934
Primary key
I-13
Foreign key
Primary key
I-14
Data is displayed
LOC LOC ------------------------NEW YORK NEW YORK DALLAS DALLAS CHICAGO CHICAGO BOSTON BOSTON I-15
User tables
I-16
Data dictionary
I-17
Defining an Object
An object An object Is a person, place, or thing Is a person, place, or thing Knows things about itself and performs Knows things about itself and performs actions actions Has an identity Has an identity
Customers
I-19
Business
SQL SQL
PL/SQL PL/SQL
Oracle7/8
Database
I-21
SQL Statements
SELECT INSERT UPDATE DELETE CREATE ALTER DROP RENAME TRUNCATE COMMIT ROLLBACK SAVEPOINT GRANT REVOKE
I-22
Transaction control
About PL/SQL
PL/SQL is an extension to SQL with PL/SQL is an extension to SQL with design features of programming design features of programming languages. languages. Data manipulation and query statements Data manipulation and query statements of SQL are included within procedural of SQL are included within procedural units of code. units of code.
I-23
PL/SQL Environment
PL/SQL engine PL/SQL block PL/SQL block PL/SQL SQL Procedural Statement Executor
I-24
Benefits of PL/SQL
Integration Integration
Application
Shared library
I-25
Oracle Server
Benefits of PL/SQL
Improve Performance Improve Performance
SQL
Application Application
Application Application
I-26
Benefits of PL/SQL
Modularize program development Modularize program development
Anonymous Anonymous block block Stored Stored procedure/ procedure/ function function Application Application procedure/ procedure/ function function
END;
I-27
Benefits of PL/SQL
It is portable. It is portable. You can declare identifiers. You can declare identifiers. You can program with procedural You can program with procedural language control structures. language control structures. It can handle errors. It can handle errors.
I-28
Benefits of PL/SQL
It is portable. It is portable. You can declare identifiers. You can declare identifiers. You can program with procedural You can program with procedural language control structures. language control structures. It can handle errors. It can handle errors.
I-29
EMP
EMPNO ENAME JOB MGR EMPNO ENAME JOB MGR --------- ---------- --------- ----------------- ---------- --------- --------7839 KING PRESIDENT 7839 KING PRESIDENT 7698 BLAKE MANAGER 7839 7698 BLAKE MANAGER 7839 7782 CLARK MANAGER 7839 7782 CLARK MANAGER 7839 7566 JONES MANAGER 7839 7566 JONES MANAGER 7839 7654 MARTIN SALESMAN 7698 7654 MARTIN SALESMAN 7698 7499 ALLEN SALESMAN 7698 7499 ALLEN SALESMAN 7698 7844 TURNER SALESMAN 7698 7844 TURNER SALESMAN 7698 DEPT 7900 JAMES CLERK 7698 7900 JAMES CLERK 7698 SALESMAN 7698 7521 SALESMAN 7698 DEPTNO 7521 WARD LOC DEPTNO DNAME WARD DNAME LOC ANALYST 7566 7902 FORD ANALYST 7566 --------- 7902 FORD --------- -------------- ----------------------- ---------7369 10 ACCOUNTING CLERK NEW 7902 7369 SMITH SMITH CLERK NEW 7902 10 ACCOUNTING 7788 SCOTT ANALYST 7566 7788 SCOTT ANALYST 7566 YORK YORK CLERK 7788 7876 ADAMS CLERK 7788 20 7876 ADAMS DALLAS 20 RESEARCH RESEARCH DALLAS 7934 MILLER CLERK 7782 CLERK 7782 30 SALES MILLER CHICAGO 30 7934 SALES CHICAGO 40 OPERATIONS BOSTON 40 OPERATIONS BOSTON
I-30
Summary
Relational databases are composed of Relational databases are composed of relations, managed by relational relations, managed by relational operations, and governed by data operations, and governed by data integrity constraints. integrity constraints. Oracle Server allows you to store and Oracle Server allows you to store and manage information by using the SQL manage information by using the SQL language and PL/SQL engine. language and PL/SQL engine. PL/SQL is an extension to SQL with PL/SQL is an extension to SQL with design features of programming design features of programming languages. languages.
I-31
I-32