introduction
DESCRIPTION
Introduction. 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 - PowerPoint PPT PresentationTRANSCRIPT
Copyright Oracle Corporation, 1998. All rights reserved.
II
IntroductionIntroduction
I-2 Copyright Oracle Corporation, 1998. All rights reserved.
ObjectivesObjectives
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 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
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 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-3 Copyright Oracle Corporation, 1998. All rights reserved.
System Development Life CycleSystem Development Life Cycle
StrategyStrategyandand
AnalysisAnalysisDesignDesign
BuildBuildandand
DocumentDocument
TransitionTransition
ProductionProduction
I-5 Copyright Oracle Corporation, 1998. All rights reserved.
Data Storage on Different MediaData Storage on Different Media
Electronic Electronic spreadsheetspreadsheet
Filing cabinetFiling cabinet
DatabaseDatabase
SALGRADESALGRADE GRADE LOSAL HISAL
--------- --------- ---------
1 700 1200
2 1201 1400
3 1401 2000
4 2001 3000
5 3001 9999
SALGRADESALGRADE GRADE LOSAL HISAL
--------- --------- ---------
1 700 1200
2 1201 1400
3 1401 2000
4 2001 3000
5 3001 9999
DEPTDEPT DEPTNO DNAME LOC
--------- -------------- ----------
10 ACCOUNTING NEW
YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
DEPTDEPT DEPTNO DNAME LOC
--------- -------------- ----------
10 ACCOUNTING NEW
YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
I-6 Copyright Oracle Corporation, 1998. All rights reserved.
Relational Database ConceptRelational 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
• 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-7 Copyright Oracle Corporation, 1998. All rights reserved.
Definition of a Relational Database
Definition of a Relational Database
A relational database is a collection of A relational database is a collection of relations or two-dimensional tables.relations or two-dimensional tables.A relational database is a collection of A relational database is a collection of relations or two-dimensional tables.relations or two-dimensional tables.
DatabaseDatabase
DEPTNO DNAME LOC
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
DEPTNO DNAME LOC
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
Table Name: Table Name: DEPTDEPT
EMPNO ENAME JOB DEPTNO
7839 KING PRESIDENT 10
7698 BLAKE MANAGER 30
7782 CLARK MANAGER 10
7566 JONES MANAGER 20
EMPNO ENAME JOB DEPTNO
7839 KING PRESIDENT 10
7698 BLAKE MANAGER 30
7782 CLARK MANAGER 10
7566 JONES MANAGER 20
Table Name: Table Name: EMPEMP
I-8 Copyright Oracle Corporation, 1998. All rights reserved.
Data ModelsData Models
Model ofModel ofsystemsystem
in client’sin client’smindmind
Entity model ofEntity model ofclient’s modelclient’s model
Table modelTable modelof entity modelof entity model
Tables on diskTables on disk
ServerServer
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 . . .”
• 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 ModelEntity Relationship Model
EMPLOYEEEMPLOYEE#* #* numbernumber** namenameoo job titlejob title
EMPLOYEEEMPLOYEE#* #* numbernumber** namenameoo job titlejob title
DEPARTMENTDEPARTMENT#* #* numbernumber** namenameoo locationlocation
DEPARTMENTDEPARTMENT#* #* numbernumber** namenameoo locationlocation
assigned toassigned toassigned toassigned to
composed ofcomposed ofcomposed ofcomposed of
I-10 Copyright Oracle Corporation, 1998. All rights reserved.
Entity Relationship Modeling Conventions
Entity Relationship Modeling Conventions
EntityEntitySoft boxSoft boxSingular, unique nameSingular, unique nameUppercaseUppercaseSynonym in parenthesesSynonym in parentheses
AttributeAttributeSingular nameSingular nameLowercaseLowercaseMandatory marked with “*”Mandatory marked with “*”Optional marked with “o”Optional marked with “o”
Unique Identifier (UID)Unique Identifier (UID)Primary marked with “#”Primary marked with “#”Secondary marked with “(#)”Secondary marked with “(#)”
EMPLOYEEEMPLOYEE#* #* numbernumber** namenameoo job titlejob title
EMPLOYEEEMPLOYEE#* #* numbernumber** namenameoo job titlejob title
DEPARTMENTDEPARTMENT#* #* numbernumber** namenameoo locationlocation
DEPARTMENTDEPARTMENT#* #* numbernumber** namenameoo locationlocation
assigned toassigned toassigned toassigned to
composed ofcomposed ofcomposed ofcomposed of
I-12 Copyright Oracle Corporation, 1998. All rights reserved.
Relational Database TerminologyRelational 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
I-13 Copyright Oracle Corporation, 1998. All rights reserved.
Relating Multiple TablesRelating Multiple Tables
• Each row of data in a table is uniquely identified by a primary key (PK).
• Each row of data in a table is uniquely identified by a primary key (PK).
Table Name: Table Name: EMPEMP Table Name: Table Name: DEPTDEPT
Primary keyPrimary key Primary keyPrimary key
• You can logically relate data from multiple tables using foreign keys (FK).
• You can logically relate data from multiple tables using foreign keys (FK).
Foreign keyForeign 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
I-14 Copyright Oracle Corporation, 1998. All rights reserved.
Relational Database PropertiesRelational Database Properties
A relational database 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
A relational database 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-15 Copyright Oracle Corporation, 1998. All rights reserved.
Communicating with a RDBMS Using SQL
Communicating with a RDBMS Using SQL
DatabaseDatabase
SQL> SELECT loc 2 FROM dept;
SQL> SELECT loc 2 FROM dept;
SQL statementSQL statementis enteredis entered Statement is sent to Statement is sent to
databasedatabase
LOC
-------------
NEW YORK
DALLAS
CHICAGO
BOSTON
LOC
-------------
NEW YORK
DALLAS
CHICAGO
BOSTON
Data is displayedData is displayed
I-16 Copyright Oracle Corporation, 1998. All rights reserved.
Relational Database Management SystemRelational Database Management System
User tablesUser tables Data Data dictionarydictionary
ServerServer
I-17 Copyright Oracle Corporation, 1998. All rights reserved.
Oracle8: Object Relational Database Management System
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
• User-defined data types and objects
• Fully compatible with relational database
• Support of multimedia and large objects
• High-quality database server features
I-18 Copyright Oracle Corporation, 1998. All rights reserved.
Defining an ObjectDefining an Object
An objectAn object
• Is a person, place, or thing
• Knows things about itself and performs actions
• Has an identity
An objectAn object
• Is a person, place, or thing
• Knows things about itself and performs actions
• Has an identity
I am a clock. I knowI am a clock. I knowmy my time zonetime zone, and I, and I
can can display time.display time.
I-19 Copyright Oracle Corporation, 1998. All rights reserved.
Using an Object ModelUsing 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.
• Objects model a problem to solve.
• The model is stated in terms of the interactions between objects.
• Object models closely resemble the real world.
CustomersCustomers BusinessBusiness
BuyBuy
SellSell
I-20 Copyright Oracle Corporation, 1998. All rights reserved.
Oracle Complete SolutionOracle Complete Solution
SQLSQLSQLSQL PL/SQLPL/SQLPL/SQLPL/SQL
Oracle7/8Oracle7/8
ApplicationsApplications HRHR FinancialsFinancials ManufacturingManufacturing ......
ApplicationsApplications HRHR FinancialsFinancials ManufacturingManufacturing ...... Oracle DesignerOracle DesignerOracle DesignerOracle Designer
Oracle DeveloperOracle DeveloperOracle DeveloperOracle Developer
Data tablesData tables
Data Data dictionarydictionary DatabaseDatabase
SQL* PlusSQL* PlusSQL* PlusSQL* Plus
Discoverer Discoverer Discoverer Discoverer
I-21 Copyright Oracle Corporation, 1998. All rights reserved.
SQL StatementsSQL StatementsSELECT SELECT INSERTINSERTUPDATEUPDATEDELETEDELETE
CREATECREATEALTERALTERDROPDROPRENAMERENAMETRUNCATETRUNCATE
COMMITCOMMITROLLBACKROLLBACKSAVEPOINTSAVEPOINT
GRANTGRANTREVOKEREVOKE
Data retrieval Data retrieval
Data manipulation language (DML)Data manipulation language (DML)
Data definition language (DDL)Data definition language (DDL)
Transaction controlTransaction control
Data control language (DCL)Data control language (DCL)
I-22 Copyright Oracle Corporation, 1998. All rights reserved.
About PL/SQLAbout 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.
• 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 EnvironmentPL/SQL Environment
PL/SQLblock
PL/SQL engine
Oracle Server
ProceduralStatementExecutor
PL/SQL
SQL
SQL Statement Executor
PL/SQLblock
I-24 Copyright Oracle Corporation, 1998. All rights reserved.
Tables Used in the CourseTables 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
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
EMPEMP
DEPTDEPT
DEPTNO DNAME LOC
--------- -------------- ----------
10 ACCOUNTING NEW
YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
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
GRADE LOSAL HISAL
--------- --------- ---------
1 700 1200
2 1201 1400
3 1401 2000
4 2001 3000
5 3001 9999
SALGRADESALGRADE
I-25 Copyright Oracle Corporation, 1998. All rights reserved.
SummarySummary
• 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.
• 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.