DB BKP
DB BKP
DB BKP
Database Backup
Database Backup is storage of data that means the copy of the data.
It is a safeguard against unexpected data loss and application errors.
It protects the database against data loss.
If the original data is lost, then using the backup it can reconstructed.
2. Logical backup
Logical Backup contains logical data which is extracted from a database.
It includes backup of logical data like views, procedures, functions, tables, etc.
It is a useful supplement to physical backups in many circumstances but not a sufficient
protection against data loss without physical backups, because logical backup provides only
structural information.
Importance Of Backups
Planning and testing backup helps against failure of media, operating system, software and
any other kind of failures that cause a serious data crash.
It determines the speed and success of the recovery.
Physical backup extracts data from physical storage (usually from disk to tape). Operating
system is an example of physical backup.
Logical backup extracts data using SQL from the database and store it in a binary file.
Logical backup is used to restore the database objects into the database. So the logical
backup utilities allow DBA (Database Administrator) to back up and recover selected
objects within the database.
Methods of Backup
The different methods of backup in a database are:
Full Backup - This method takes a lot of time as the full copy of the database is
made including the data and the transaction records.
Transaction Log - Only the transaction logs are saved as the backup in this method.
To keep the backup file as small as possible, the previous transaction log details are
deleted once a new backup record is made.
Differential Backup - This is similar to full backup in that it stores both the data and
the transaction records. However only that information is saved in the backup that has
changed since the last full backup. Because of this, differential backup leads to
smaller files.
3. Network Failure
A network failure occurs when a client – server configuration or distributed database system
are connected by communication networks.
4. Disk Failure
Disk Failure occurs when there are issues with hard disks like formation of bad sectors, disk
head crash, unavailability of disk etc.
5. Media Failure
Media failure is the most dangerous failure because, it takes more time to recover than any
other kind of failures.
A disk controller or disk head crash is a typical example of media failure.
Natural disasters like floods, earthquakes, power failures, etc. damage the data.
6. User Error
Normally, user error is the biggest reason of data destruction or corruption in a database. To
rectify the error, the database needs to be restored to the point in time before the error
occured.
Hardware protection is divided into 3 categories: CPU protection, Memory Protection, and
I/O protection. These are explained as following below.
1. CPU Protection:
CPU protection is referred to as we can not give CPU to a process forever, it should be
for some limited time otherwise other processes will not get the chance to execute the
process. So for that, a timer is used to get over from this situation. which is basically
give a certain amount of time a process and after the timer execution a signal will be
sent to the process to leave the CPU. hence process will not hold CPU for more time.
2. Memory Protection:
In memory protection, we are talking about that situation when two or more processes
are in memory and one process may access the other process memory. and to protecting
this situation we are using two registers as:
Bare register
Limit register
So basically Bare register store the starting address of program and limit register store
the size of the process, so when a process wants to access the memory then it is checked
that it can access or can not access the memory.
3. I/O Protection:
So when we ensuring the I/O protection then some cases will never have occurred in
the system as:
1. Termination I/O of other process
2. View I/O of other process
3. Giving priority to a particular process I/O
Redundancy
Data redundancy is a condition created within a database or data storage technology in which
the same piece of data is held in two separate places.
This can mean two different fields within a single database, or two different spots in multiple
software environments or platforms. Whenever data is repeated, this basically constitutes data
redundancy. This can occur by accident, but is also done deliberately for backup and recovery
purposes.
Hardware redundancy
Hardware redundancy is achieved by providing two or more physical copies of a hardware
component. When other techniques, such as use of more reliable components,
manufacturing quality control, test, design simplification, etc., have been exhausted,
hardware redundancy may be the only way to improve the dependability of a system.
What Is Recovery?
Recovery is the process of restoring a database to the correct state in the event of a failure.
It ensures that the database is reliable and remains in consistent state in case of a failure.
Database Recovery
There are two methods that are primarily used for database recovery. These are:
Log based recovery - In log based recovery, logs of all database transactions are
stored in a secure area so that in case of a system failure, the database can recover the
data. All log information, such as the time of the transaction, its data etc. should be
stored before the transaction is executed.
Shadow paging - In shadow paging, after the transaction is completed its data is
automatically stored for safekeeping. So, if the system crashes in the middle of a
transaction, changes made by it will not be reflected in the database.
Log-Based Recovery
Logs are the sequence of records, that maintain the records of actions performed by a
transaction.
In Log – Based Recovery, log of each transaction is maintained in some stable storage. If
any failure occurs, it can be recovered from there to recover the database.
The log contains the information about the transaction being executed, values that have been
modified and transaction state.
All these information will be stored in the order of execution.
Example:
Assume, a transaction to modify the address of an employee. The following logs are written
for this transaction,
Log 1: Transaction is initiated, writes 'START' log.
Log: <Tn START>
There are two methods of creating the log files and updating the database,
1. Deferred Database Modification
2. Immediate Database Modification
1. In Deferred Database Modification, all the logs for the transaction are created and stored
into stable storage system. In the above example, three log records are created and stored it in
some storage system, the database will be updated with those steps.
2. In Immediate Database Modification, after creating each log record, the database is
modified for each step of log entry immediately. In the above example, the database is
modified at each step of log entry that means after first log entry, transaction will hit the
database to fetch the record, then the second log will be entered followed by updating the
employee's address, then the third log followed by committing the database changes.
Chapter 9
Integrity constraints are a set of rules. It is used to maintain the quality of information.
Integrity constraints ensure that the data insertion, updating, and other processes have
to be performed in such a way that data integrity is not affected.
Thus, integrity constraint is used to guard against accidental damage to the database.
1. Domain constraints
Domain constraints can be defined as the definition of a valid set of values for an
attribute.
The data type of domain includes string, character, integer, time, date, currency,
etc. The value of the attribute must be available in the corresponding domain.
Example:
Example:
Example:
4. Key constraints
Keys are the entity set that is used to identify an entity within its entity set uniquely.
An entity set can have multiple keys, but out of which one key will be the primary
key. A primary key can contain a unique and null value in the relational table.
Example:
NOT NULL and CHECK integrity constraints are allowed. They are not a problem for
parallel DML because they are enforced on the column and row level, respectively.
Restrictions for referential integrity occur whenever a DML operation on one table could
cause a recursive DML operation on another table. These restrictions also apply when, to
perform an integrity check, it is necessary to see simultaneously all changes made to the
object being modified.
Delete Cascade
Deletion on tables having a foreign key with delete cascade is not parallelized because
parallel execution servers attempt to delete rows from multiple partitions (parent and child
tables).
Self-Referential Integrity
DML on tables with self-referential integrity constraints is not parallelized if the referenced
keys (primary keys) are involved. For DML on all other columns, parallelism is possible.
Deferrable Integrity Constraints
If any deferrable constraints apply to the table being operated on, the DML operation is not
executed in parallel.
These listed circumstances mostly signify the areas in which the organization should focus on
reducing the risk that is the chance of incurring loss or damage to data within a database.
First, from accidental loss and corruption, and Second, from deliberate unauthorized attempts
to access or alter that data. Secondary concerns include protecting against undue delays in
accessing or using data, or even against interference to the point of denial of service. .
Ensure that physical damage to the server doesn’t result in the loss of data.
Database Users
Database users are the one who really use and take the benefits of database. There will be
different types of users depending on their need and way of accessing the database.
It is a person or a team, who is responsible for managing the overall database management
system.
It is the leader of the database. It is like a super user of the system.
It is responsible for the administration of all the three levels of the database.
2. Database Designers:
Database designers design the appropriate structure for the database, where we share data.
3. System Analyst:
System analyst is responsible for the design, structure and properties of database. All the
requirements of the end users are handled by system analyst. Feasibility, economic and
technical aspects of DBMS is the main concern of system analyst.
4. Application Programmers:
Application programmers are computer professionals, who write application programs.
6. Sophisticated Users:
Sophisticated users can be engineers, scientists, business analyst, who are familiar with the
database. These users interact with the database but they do not write programs
Privileges
A privilege is permission to access a named object in a prescribed manner; for example,
permission to query a table. Privileges can be granted enable a particular user to connect to
the database (create a session); select rows from someone else's table; or execute someone
else's stored procedure.
Database privileges
A privilege is a right to execute a particular type of SQL statement or to access another user's
object. Some examples of privileges include:
• The right to connect to the database (create a session)
• The right. to create a table
• The right to select rows from another user's table
• The right to execute another user's stored procedure
Privileges are granted to users so that these can accomplish tasks required for their job. You
should grant a privilege only to user who absolutely requires the privilege to accomplish
necessary work. Excessive granting of unnecessary privileges can lead to compromised
security.
System privileges
A system privilege is the right to perform a particular action, on a particular type of object.
For example, the privileges to create tables and to delete the (OWS of any table in a database
are system privileges. In many commercial database management systems there are hundreds
of distinct system privileges.
Object privileges
An object privilege is a privilege or right to perform a particular action on a specific table,
view, sequence, procedure, function, or package. For example, the privilege to delete rows
from the table DEPT is an object privilege.
Object privileges granted for a table, view, sequence, procedure, function, or package apply
whether referencing the base object by name or using a synonym.
Roles
A role is a mechanism that can be used to provide authorization. A single person or a group
of people can be granted a role or a group of roles. One role can be granted in turn to other
roles. By defining different types of roles, administrators can manage access privileges much
more easily.
Database management systems provide for easy and controlled privilege management
through roles. Roles are named groups of related privileges that you grant to users or other
roles. Roles are designed to ease the administration of end-user system and object privileges.
The following properties of roles allow for easier privilege management vvithin a database:
• Reduced privilege administration - Rather them explicitly granting the same set of
privileges to several uses, you can grant the privileges for a group of related users to a role.
Then, only the role needs to be granted to each member of the group.
• Dynamic privilege management - If the privileges of a group must change, only the
privileges of the role need to be modified.
• Selective availability of privileges - You can selectively enable or disable the roles granted
to a user. This allows specific control of a user's privileges in any given situation.
• Application-specific security - you can protect role use with a password. Applications can
be created specifically to enable a role when supplied the correct password. Users cannot
enable the role if they do not know the password.
• Remove DELETE and UPDATE authority on the SAL and JOB columns of the EMP table
from user 'AJAY'.
REVOKE DELETE, UPDATE (SAL, JOB) ON EMP FROM AJAY;