I
Introduction
Database Concept
• Data
– Facts and Figures
• Database
– Collection of data in a form of two-
dimensional table
– Organised collection of information
• DBMS
– Program that stores, retrieves and
modifies data in the database
I-2
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 Filing cabinet
spreadsheet
I-3
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-4
Relational Database Definition
A relational database is a collection of
relations or two-dimensional tables.
Database
Table Name: EMP Table Name: DEPT
EMPNO ENAME JOB DEPTNO DEPTNO DNAME LOC
7839 KING PRESIDENT 10 10 ACCOUNTING NEW YORK
7698 BLAKE MANAGER 30 20 RESEARCH DALLAS
7782 CLARK MANAGER 10 30 SALES CHICAGO
7566 JONES MANAGER 20 40 OPERATIONS BOSTON
I-5
Relational Database Terminology
2 3 4
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
6
------------- ------------ --------------------- -------- ---------------- ----------- -------------- -----------
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 5 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
1 7934 MILLER CLERK 7782 23-JAN-82 1300 10
I-6
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 Table Name: DEPT
EMPNO ENAME JOB DEPTNO DEPTNO DNAME LOC
7839 KING PRESIDENT 10 10 ACCOUNTING NEW YORK
7698 BLAKE MANAGER 30 20 RESEARCH DALLAS
7782 CLARK MANAGER 10 30 SALES CHICAGO
7566 JONES MANAGER 20 40 OPERATIONS BOSTON
Primary key Foreign key Primary key
I-7
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-8
Communicating with a RDBMS
Using SQL
SQL statement
is entered Statement is sent to
SQL> SELECT loc database
2 FROM dept;
Database
Data is displayed
LOC
-------------
NEW YORK
DALLAS
CHICAGO
BOSTON
I-9
SQL Statements
SELECT Data retrieval
INSERT
UPDATE Data manipulation language (DML)
DELETE
CREATE
ALTER
DROP Data definition language (DDL)
RENAME
TRUNCATE
COMMIT
ROLLBACK Transaction control
SAVEPOINT
GRANT Data control language (DCL)
REVOKE
I-10
Tables Used in the Course
EMP
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 1500 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
DEPT 7900 JAMES CLERK 7698 03-DEC-81 950 30
DEPTNO 7521
DNAMEWARD SALESMAN
LOC 7698 22-FEB-81 1250 500 30
--------- 7902 FORD
-------------- ANALYST
---------- 7566 03-DEC-81 SALGRADE
3000 20
10 7369 SMITH
ACCOUNTING CLERK
NEW YORK 7902 17-DEC-80 800
GRADE LOSAL 20
HISAL
20 7788 SCOTT
RESEARCH ANALYST
DALLAS 7566 09-DEC-82 3000 --------- ---------
--------- 20
30 7876
SALESADAMS CLERK
CHICAGO 7788 12-JAN-83 1100 1 700 20
1200
40 7934 MILLER
OPERATIONS CLERK
BOSTON 7782 23-JAN-82 1300 2 1201 10
1400
3 1401 2000
4 2001 3000
5 3001 9999
I-11
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-12
I-13