0% found this document useful (0 votes)
4 views

unit 5 dbms

This document covers database administration, focusing on user management, privileges, and backup strategies. It details how to create, alter, and delete users, as well as the types of privileges (system and object) that can be assigned. Additionally, it discusses various types of database failures and the importance of backup, outlining physical and logical backup methods and their respective advantages and disadvantages.

Uploaded by

renukabhasme03
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

unit 5 dbms

This document covers database administration, focusing on user management, privileges, and backup strategies. It details how to create, alter, and delete users, as well as the types of privileges (system and object) that can be assigned. Additionally, it discusses various types of database failures and the importance of backup, outlining physical and logical backup methods and their respective advantages and disadvantages.

Uploaded by

renukabhasme03
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

UNIT 5 Database Administration [08 marks]

5.1 Types of user


(Provided in separate pdf)

5.1.2Creating,Altering,and Deleting Users in a Database:

 Creating a user:
-Creating a user in a DBMS involves defining the username and password,
and assigning the user specific roles or permissions.
-Geneally,this task is performed by the database administrator.
-The CREATE USER statement is used to create new user accounts for
database access. It enables database administrators to define which users
can connect to the database server and specify their login credentials.

Syntax:
CREATE USER username IDENTIFIED BY password;

username: It is the name that the user wants to give to the database account.
password:It is the password used to assign to the username.The password is
specified in the IDENTIFIED BY clause.

 Altering a user:
-ALTER USER command to change the settings, such as the password, for
the specified user

Syntax:
ALTER USER username IDENTIFIED BY new_password;

 Deleting a User:
- To remove a user from the database,you would use the DROP USER
command.

Syntax:
Drop user username;
Assign Privileges to users-

Database privileges:

- privileges is a term which determine the level of access and actions a user can
perform on a database.
- Privileges can be categorized into system privileges and object privileges
based on the type of actions allowed on the database system and its objects.

1. System Privileges

- System privileges refer to the rights granted to a user to perform certain administrative
tasks or actions that affect the entire database system.

-It typically involve actions related to creating,modifying,or managing database objects,


managing users, or performing system-level tasks.

Common System Privileges:

 CREATE USER:Allows a user to create other users.


 DRO P USER:Allows a user to drop(delete) other users.
 CREATE TABLE:Allows a user to create tables in the database.
 CREATE PROCEDURE:Allows a user to create stored procedures and
functions.
 CREATE ROLE:Allows a user to create roles,which are collections of privileges.
 GRANT:Allows a user to assign privileges to other users or roles.
 REVOKE:Allows a user to remove privileges from other users or roles.

2. Object Privileges

- Object privileges refer to the rights granted to a user to perform actions on specific
Database objects(e.g.,tables,views,procedures,etc.).

- They are more granular and control access at the level of specific objects within the
database.

Common Object Privileges:

 SELECT:Allows a user to read data from a table,view,or other select-based


objects.
 INSERT:Allows a user to insert data into a table or view.
 UPDATE:Allows a user to modify data in a table or view.
 DELETE:Allows a user to delete data from a table or view.
 ALTER:Allows a user to modify the structure of a database object
 DROP:Allows a user to delete a database object(e.g.,table,view, etc.).
 INDEX:Allows a user to create indexes on a table or view.

Granting and revoking privileges:

1. GRANT Command

- The GRANT statement is used to assign specific privileges or permissionsto a


user,role, or group on a particular database object (like a table, view, stored procedure,
etc.).

- The privileges can include actions like SELECT, INSERT, UPDATE, DELETE, and
more.

Syntax:

GRANT privileges
ON object_name
TO user_name
[WITHGRANTOPTION];

 privileges:The types of privilege being granted(e.g.,SELECT,INSERT, UPDATE,


EXECUTE).
 object_name:The name of the database object(e.g.,table,view,procedure).
 user_name:The user to whom the privilege is being granted.
 WITH GRANT OPTION: This allows the grantee to grant the same privilege to
other users.

Examples of GRANT Command:

1. Granting SELECT privilege on a table: If you want to grant a user1 the ability
to read data from a table employees:

GRANT SELECT ON employees TO user1;

This allows user1 to perform SELECT queries on the employees table.

2. Granting multiple privileges: To give a user multiple permissions(e.g.,SELECT,


INSERT, and UPDATE) on the employees table to user1:

GRANT SELECT,INSERT,UPDATE ON employees TO user1;


2. REVOKE Command

- The REVOKE statement is used to remove or takeback privileges that were


previously granted to a user.

-After a privilege is revoked,the user can no longer has access to the specified object unless
the privilege is granted again.

Syntax:

REVOKE privilege
ON object_name
FROM user_name;

 privilege:The type of privilege being revoked(e.g.,SELECT,INSERT,etc.).


 object_name:The database object from which the privilege is being revoked.
 user_name:The user or role from whom the privilege is being revoked.

Examples of REVOKE Command:

1. Revoking a single privilege: If you want to revoke the SELECT privilege from
user1 on the employees table:

REVOKE SELECT ON employees FROM user1;

This removes the SELECT privilege from user1, so they can no longer query the
employees table.

2. Revoking multiple privileges: If you want to revoke multiple privileges at once,


such as SELECT and INSERT:

REVOKE SELECT,INSERT ON employees FROM user1;


5.2 Database backup:

Types of failure:
In a Database Management System(DBMS), failures can occur for various reasons,
ranging from hardware issues to software bugs or human errors. These failures can result
in data loss, inconsistency, or system unavailability. Understanding the types of failures
is crucial for designing systems that ensure data reliability and recovery.

1. Transaction Failure

A transaction failure occurs when a transaction (an operation or set of operations)


cannot be completed successfully.These failures can be caused by various reasons during
the execution of a transaction.

Common Causes:

 Logic or application errors: Errors in the application code or business logic that
cause the transaction to violate constraints (e.g. foreign key violations, division by
zero, etc.).
 Resource unavailability: Lack of necessary resources, such as memory, CPU, or
disk space, causing the transaction to fail.
 Deadlocks: When two or more transactions are stuck, each waiting for the other to
release resources, leading to a deadlock.
 Timeouts: A transaction may fail if it does not complete within a predefined time
limit.

2. System Crash

A system crash occurs when the DBMS or the underlying system (e.g., the operating
system or hardware) experiences a failure, causing the database to become inaccessible.

Common Causes:

 Power failure: Loss of power can cause a system to crash.


 Hardware failure: Faulty disks, memory or CPU can lead to system crashes.
 Software bugs: Operating system or DBMS software bugs can result in a crash.
 Resource exhaustion: Overuse of system resources (e.g., memory leaks) can
cause a crash.
3. Media Failure(DiskFailure)

A media failure refers to a problem with the physical storage medium (e.g., hard drive,
SSD) where the database is stored. It happens when the hardware storing the data
becomes corrupt or unavailable.

Common Causes:

 Disk corruption: Physical damage to the storage medium that corrupts data.
 Hardware malfunction: A malfunctioning storage device can lead to data loss.
 File system corruption: If the file system becomes corrupted, the database files
may be inaccessible.
 Dataloss: If a disk fails and there are no adequate backups, data may be
permanently lost.

4. Logical Failure

A logical failure occurs when the database is logically inconsistent or incorrect, even if
the system and hardware are functioning correctly. These failures typically result from
human errors or software bugs that violate the logical integrity of the database.

Common Causes of failures:


 Application bugs: Bugs in the application that mismanage data or create
invaliddata entries.
 Data corruption: Logical inconsistencies in the data, such as violating constraints
or integrity rules.
 Schema changes:Incorrect schema modifications(e.g.,dropping columns or
changing data types) that lead to application failures.
 User errors:Human mistakes,such as incorrect SQL queries that delete or modify
large volumes of data.
 Violation of integrity constraints: E.g., violating referential integrity constraints
(foreign key violations).

Causes of failure:

- Database failure can occur due to a wide variety of reasons, which can be categorized
into hardware, software, human error, and environmental factors.

1. Hardware Failures

 Disk Failures: Hard drives or storage devices can fail, resulting in data loss or
corruption.
 Power Failures: Sudden power outages can disrupt database operations and lead
to inconsistencies or corruption.
 Memory Failures:Issues with RAM or system memory can cause database
operations to malfunction, leading to crashes or data corruption.
 Network Failures: Disruptions in network connectivity can prevent access to the
database or cause timeouts in distributed databases.
 Server Failures: Server crashes or hardware malfunctions can cause the database
service to become unavailable.

2. Software Failures

 Bugs in Database Management System(DBMS): Software bugs in the DBMS


itself can cause unexpected crashes, corruption, or incorrect behavior.
 Corruption o Database Files: If database files become corrupted due to software
issues such as improper shutdowns or conflicts in the DBMS, it can cause data loss
or failures.
 Incompatible Software Versions: Upgrading DBMS software or related tools
without proper testing can lead to compatibility issues, resulting in failure or
degraded performance.
 Concurrency Issues: Problems in handling simultaneous transactions e.g.,
deadlocks, race conditions can lead to inconsistent database states.

3. Human Errors

 Data Corruptionor Loss: Mistakes made during data entry, data migrations, or
updates can lead to corruption or loss of data.
 Improper Configuration: Misconfigurations of the DBMS, such as incorrect
indexing, security settings, can cause poor performance or failure.
 Accidental Deletion: Admins or users accidentally deleting tables, records, or
configurations can cause irreparable damage to a database.
 Poor Backup and Recovery Practices: Failure to implement a proper backup
strategy or neglecting to test recovery procedures can lead to permanent data loss
in the event of a failure.

4. Environmental Factors

 Natural Disasters: Events like earthquakes, floods, or fires can physically


damage the hardware that hosts the database, leading to total system failure.
 Temperature or Humidity Variations: Extreme environmental conditions can
cause physical damage to servers, hard drives, or networking equipment, leading
to failures.
 Improper Cooling: Servers not adequately cooled may overheat and fail, causing
the database to crash or the underlying hardware to become damaged.
5. Security Breaches

 Cyber Attacks: Malware, distributed denial-of-service(DDoS)attackscan


compromise the integrity and availability of a database.
 SQL Injection: Poorly written queries and lack of security measures can expose
the database to SQL injection attacks, which can corrupt or manipulate data.
 Unauthorized Access: A breach of access controls or insufficient authentication
can allow unauthorized users to alter, delete, or steal data.

6. Software and Application Bugs

 Application-Level Bugs: Problems in the applications that interface with the


database, such as bugs in SQL queries, connection management, or data
processing logic, can cause the database to become unresponsive or corrupted.
 Faulty Patches/Updates: Applying patches or updates that are incompatible with
the database can result in crashes or malfunctioning services.

7. Database Design Issues

 Poor Schema Design: Inefficient or incorrect database schema design can


degrade performance, corrupted data, or failure to meet business requirements.
 Lack of Indexing: Missing or improper indexing can cause the database to
perform poorly under heavy load or with large datasets, potentially causing
timeouts or crashes.
 Normalization Problems: Failing to properly normalize or denormalize the data
can lead to issues like redundant data or inefficient queries, affecting performance
and stability.

8. Concurrency Issues

 Deadlocks: If two or more transactions are waiting for each other to release locks,
a deadlock can occur, causing the database to hang or crash.

9. Capacity or Scalability Issues

 Resource Exhaustion: Databases may fail if they run out of critical resources like
disk space, memory, or CPU, especially under high load or unexpected spikes in
traffic.
 Scaling Problems: If the database is not scaled properly to handle increased loads
it may experience performance degradation or complete failure.

10. Out-of-Resource Conditions


 Out of Disk Space: Running out of storage space can cause databases to stop
accepting new data or result in data corruption.
 Out of Memory(OOM): If the database system exhausts the available system
memory, it may crash or become unresponsive.
11. Lack of Maintenance

 Failure to Apply Patchesor Updates: Failing to update the database software,


operating system, or related components can expose the system to bugs,
vulnerabilities, and compatibility issues.
 Defragmentation Issues: Lack of regular maintenance, like disk defragmentation
or cleaning up unused database objects, can degrade database performance and
lead to failures.

Database backup introduction:

Database backup ensures that data can be recovered in the event of failure, corruption, or
accidental loss.
A database backup is a copy of storage that is stored on a server. Backup is used to
prevent unexpected data loss. If original data gets lost, then with the help of a backup, it
is easy to gain access to the data again.
A robust backup strategy typically involves a combination of different backup types and
methods, tailored to the specific needs of the organization.
There are two types of database backup.
 Physical backup
 Logical backup

Physical Backup:

Physical database backups are backups of physical files that are used to store and recover
databases.
These include different data files, control files, archived redo logs, and many more.
Typically, physical backup data is kept in the cloud, offline storage, magnetic tape, or on
a disc.

Types of Physical Backups:

1. Full Physical Backup: A backup of all the database's physical files. It provides a
complete snapshot of the database at the time of backup.
2. Incremental Physical Backup: A backup of only the changes made to the
physical files since the last backup(full or incremental). These are often combined
with transaction log backups for point-in-time recovery.
3. Differential Physical Backup: A backup of all changes made since the last full
backup, but unlike incremental backups, it does not reset after each backup.

This type of backup is useful when the user needs to restore the complete database in a
short period.
It is considered the foundation of the recovery mechanism. This form of backup has the
drawback of slowing down database operations.
Advantages:

Faster Restoration: Since it includes the actual data files, restoring a physical backup is
typically faster, especially for large databases.
Consistency: Can be made consistent with minimal impact on database performance if
transaction logs are also included (ensuring no data is missed).
Database State: Provides an exact copy of the database's files, meaning the entire database
(data, schema and indexes) can be restored without the need for additional steps

Disadvantage:

Size: Backup files tend to be large, as they involve copying entire database files, which
can be resource-intensive, especially for large databases.
Complexity: Requires more careful management of the physical files (e.g., ensuring that
all files are included for a complete backup and restoring them in the correct order).

It is preferable in following cases:

Large Databases: When backing up large or complex databases with many objects, physical
backups are more efficient in terms of both time and space.
Full Restores: For systems where the entire database needs to be restored quickly, such as in
disaster recovery scenarios.

Logical Backup:

A logical backup focuses on the logical structure of the database, such as the schema,
tables, views, indexes, and data contained in the tables themselves. Instead of backing up
physical database files, a logical backup creates a high-level representation of the
database objects in a readable or portable format such as CSV files.
It contains logical data which is retrieved from the database. This is useful when users
want to restore or transfer a copy of the database to a different location. Logical backups
are not as secure as physical backups in preventing data loss. It only provides structural
details.
Advantages:

Portability: Logical backups can be more portable since they are stored in widely-used
formats(e.g.,SQL, CSV)that can easily be transferred or imported into different systems
or DBMSs.
Database Version Independence: Logical backups can often be restored on a different
database version or platform, which is useful when upgrading or migrating databases.
Smaller Size: Logical backups can be smaller than physical backups because they don’t
contain all the low-level system files (e.g., transaction logs, undo segments).

Disadvantages:

Slower Restoration: Restoring from a logical backup can be slower than restoring a
physical backup, especially for large databases, because the DBMS needs to recreate the
schema, indexes, and data.
Lack of Full Database State: Logical backups do not typically capture certain database-
specific configurations, transaction logs, or system files that may be needed to fully
restore the database to its exact state (e.g., to ensure point-in-time recovery).
Consistency Issues: Ensuring consistency during the backup process can be difficult,
especially for databases with high transaction volumes.

It is preferable in following cases:

Database Migration: Logical backups are ideal for migrating a database from one server to
another or even to a different DBMS (e.g., moving from MySQL to PostgreSQL).

Selective Backup: When you only need to back up specific tables, views, or schemas rather than
the entire database.

You might also like