Tuesday, April 3, 2012

ORACLE DATABASE ARCHITECTURE

Most of the organizations use the Oracle database to store and maintain data. It is also used to retrieve related information. 


The database has physical and logical structures. The physical storage can be managed without affecting the access to the logical structure as both these structures are separate.


Client/Server Architecture
In the client/server architecture, a database and its application is divided into two parts: front end or client side and back-end or server side.

The Client/Server Architecture

The Client
The client is the front end that runs a database application and is responsible for the interaction between the user and the database server through display mode, keyboard, or mouse. The client fetches the request input from the user, requests data for processing, and presents and analyzes the data managed by the server.


The Server
The server runs the Oracle database. It provides access to the data requested by the client application. In the client/server architecture, the shared data is stored on the server-side.


In the client/server architecture, the client application submits the database requests in the form of SQL and PL/SQL statements and the server application processes those statements and returns the result to the client application.


Multitier Architecture
The multitier architecture is divided into three parts: clients, application servers, and database servers.

Multitier Architecture Environment

The Client
The client or client application submits a request for an operation to be processed on the database server.


The Application Server
The application server is responsible for providing data access to the client. It processes some queries, and thus removes some of the loads from the database server. It serves as an interface between the client and the database server.


The Database Server
The database server processes the requested data of the application server for the client. The database server stores the entire data maintained by Oracle applications.

Physical Database Structures
The physical structure of the Oracle database is determined by the operating system files that form the database. The Oracle database contains some special types of files: Datafiles, Control files, and Redo Log files. These files determine the actual physical storage of data in the database.


Datafiles
Datafiles are physical files that store the data of all logical structures in the database. Oracle database can have one or more physical datafiles. The physical datafiles constitute a logical unit called a tablespace. A physical datafile can be associated with only one tablespace or one database. Datafiles are divided into the following components: Segments, Extents, and Data blocks. The essential characteristics of datafiles are as follows:
  1. If the database is running out of space, the size of datafiles will increase automatically.
  2. One or more datafiles form a logical unit, called a tablespace.
The first block in a datafile is meant for the header. The header block contains important information such as file size, block size, tablespace, and creation time. Whenever you open the Oracle database, Oracle checks whether or not the information about the datafile header matches with the information stored in the control file.


Control File
Oracle database has a control file that contains the entries showing the status of the physical structure of the database. If the physical structure of a database is changed, as in the case of the creation of a new redo log file or datafile, the database's control file gets modified to reflect these changes.
The control file contains the following types of information:

  1. Name of a database
  2. The time of the creation of a database
  3. The names and locations associated with datafiles and redo log files
  4. Information about tablespaces
  5. Log record (sequence information, etc)
  6. Information about the archived log and the current archive log mode
  7. Information about the redo log
  8. Information about the copy of a datafile
  9. The current log sequence number
  10. Information about checkpoints
In Oracle, each time you start a database instance, the control file of the database instance is used to identify the information about it. The control file also ensures that redo log files are opened for database operations. The location of the control file is specified by the control_files init param. Oracle allows users to integrate control files so that multiple copies of the control file
can be written to protect them against any failure.


Redo Log Files
In addition to datafiles and control files that store the database and show the status of the stored data, each Oracle database contains a set of two or more redo log files. The redo log files store all changes made to the data, including either committed or uncommitted changes. These changes are saved to the redo before being permanently incorporated into datafiles. The redo log file is divided into two parts: online redo log files and archived redo log files.


Online Redo Log Files
Each Oracle database has a set of two or more online redo log files that contains a redo record, which is otherwise known as redo entry. The redo record contains a group of change vectors, each of which specifies the changes made in a single block of the database. The Oracle database maintains the redo log files to minimize the loss of the database. The online redo log files store the record of the changes made to the data in the database. For example, if you change the salary of an employee in the employee table, Oracle will generate the redo record containing the change vector. The change vector will indicate the changes made in the data block for the table, the rollback data block, and the transaction table of the rollback block, and it can be used for recovery.


Archived Redo Log Files
In Oracle, you can save the filled group of redo log files to one or more offline destinations that are known as the archived redo log.


Oracle can run in either of these two modes: ARCHIVELOG and NOARCHIVELOG.


ARCHIVELOG - In this mode, Oracle archives the filled online redo logs files before reusing them in the cycle.


NOARCHIVELOG - In this mode, Oracle does not archive the filled online redo log files before reusing them in the cycle. 


Parameter Files
A parameter file contains a list of initialization parameters and their respective values. These parameters and values are used when an Oracle instance is started. The initialization parameters are stored either in parameter files (PFILEs) or server files (SPFILEs).


Alert and Trace Log Files
In Oracle, the server and background processes create special debugging files, called trace files. When a process encounters an internal error, the information related to the error is stored in the trace file.


The alert file is a special trace file. It contains the record of all significant database events and operations such as the CREATE, ALTER, and DROP on a database, tablespace, rollback data, all instance startups and shutdowns, and so on.


Logical Database Structures
Logical structures mainly consist of the data blocks, extents, segments, and tablespaces. These structures are discussed next.

Oracle Storage Structures
Data Block
A data block is the smallest unit of data storage. Data block, also known as database block, physically contains the data of logical database structures such as tables, views, and indexes. The size of a database block is specified for each Oracle database while it is being created.


Extents
Extents are the logical units of the database storage. It consists of a number of contiguous data blocks.


Segments
A segment is a container that contains objects such as tables, indexes, and so on. A segment is a set of extents allocated for a certain logical structure. For example, tables are contained in data segments, the indexes are contained in index segments. A segment and all its extents are stored in one tablespace.


Tablespaces
A tablespace is a logical storage unit that groups related data blocks, extents, and segments together. A database is logically divided into two or more tablespaces. Each tablespace has one or more datafiles and these datafiles are physically stored in the database. These datafiles store the data of all logical structures of a tablespace. 


Tables, indexes, store procedures, and other groups that belong to a tablespace are stored in the Oracle database. The tablespace builds the link between the Oracle database and the filesystem, in which the data of table, index, or store procedure is stored. 


Oracle database contains the default tablespaces such as SYSTEM and SYSAUX. These tablespaces are automatically created when you install Oracle. There are three types of tablespaces in Oracle and they are listed below:

  1. Permanent tablespaces
  2. Undo tablespaces
  3. Temporary tablespaces

No comments:

Post a Comment