0% found this document useful (0 votes)
34 views37 pages

Unit - V Database Administration

Uploaded by

sureshrmali01
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views37 pages

Unit - V Database Administration

Uploaded by

sureshrmali01
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 37

Unit - V Database

Administration
BY-
PROF-K.R.CHAURE
INTRODUCTION
A Database Administrator (DBA) is an individual or person responsible for controlling,
maintaining, coordinating, and operating a database management system. Managing,
securing, and taking care of the database systems is a prime responsibility. They are
responsible and in charge of authorizing access to the database, coordinating, capacity,
planning, installation, and monitoring uses, and acquiring and gathering software and
hardware resources as and when needed. Their role also varies from configuration,
database design, migration, security, troubleshooting, backup, and data recovery. Database
administration is a major and key function in any firm or organization that is relying on one
or more databases. They are overall commanders of the Database system.
Types of database users
1. Database Administrators (DBAs)
• Role: Responsible for managing and maintaining the database environment.
• Responsibilities: Installation, configuration, performance tuning, backup and recovery, security management, and troubleshooting.
2. Developers
• Role: Create and manage applications that interact with the database.
• Responsibilities: Write SQL queries, design database schemas, implement data access logic, and develop database-related applications.
3. End Users
• Role: Individuals who interact with the database through applications without needing technical knowledge of the database structure.
• Responsibilities: Use the database to retrieve and manipulate data through user interfaces, reports, or dashboards.
4. Data Analysts
• Role: Focus on analyzing and interpreting data stored in the database.
• Responsibilities: Write complex queries to extract insights, perform data mining, and create visualizations or reports based on the data.
5. Data Scientists
• Role: Use statistical methods and machine learning to analyze large sets of data.
• Responsibilities: Access databases to gather data for analysis, develop predictive models, and implement advanced analytics.
6. System Administrators
• Role: Manage the overall IT infrastructure, including databases.
• Responsibilities: Ensure the hardware and network systems support database operations, and perform system-level
maintenance.
7. Application Users
• Role: Users of specific applications that interact with the database (e.g., customer service representatives, sales personnel).
• Responsibilities: Access and input data relevant to their functions via application interfaces.
8. Business Analysts
• Role: Bridge the gap between IT and business, focusing on data needs from a business perspective.
• Responsibilities: Gather requirements, assess data needs, and communicate with developers and DBAs to ensure data is
available for decision-making.
9. Security Officers
• Role: Ensure database security and compliance with policies and regulations.
• Responsibilities: Monitor user access, conduct audits, and enforce security protocols.
Create and delete users
Creating and deleting users in a database management system (DBMS) involves specific SQL
commands. Below are examples of how to create and delete users in two popular DBMSs:
MySQL and Oracle.
MySQL
Creating a User
To create a new user in MySQL, you can use the following command:
CREATE USER 'username'@'host' IDENTIFIED BY 'password';

•username: The name of the user you want to create.


•host: The host from which the user will connect (use '%' for any host).
•password: The password for the new user.
Deleting a User
To delete a user in MySQL, use the following command:
DROP USER 'username'@'host';
Example:
DROP USER 'newuser'@'localhost';
Assign privileges to users
Assigning privileges to users in a database allows you to control what actions they can perform.
Below are examples of how to assign privileges to users in MySQL and Oracle.
MySQL
Granting Privileges to a User
1.Grant Specific Privileges: You can grant specific privileges on a database or table.
2.Example: Grant SELECT, INSERT, and UPDATE privileges on a specific database.
GRANT SELECT, INSERT, UPDATE ON database_name.* TO 'username'@'host';
Grant All Privileges: If you want to grant all privileges on a database:
GRANT ALL PRIVILEGES ON database_name.* TO 'username'@'host';
Grant Privileges on All Databases: To grant privileges on all databases:
GRANT ALL PRIVILEGES ON *.* TO 'username'@'host' WITH GRANT OPTION;
Flush Privileges: After granting privileges, you may need to run:
FLUSH PRIVILEGES;
Transaction:
In Database Management Systems (DBMS), a transaction is a fundamental concept
representing a set of logically related operations executed as a single
unit. Transactions are essential for handling user requests to access and modify database
contents, ensuring the database remains consistent and reliable despite various operations
and potential interruptions.
In this article, we will discuss what a transaction means, various operations of transactions,
transaction states, and properties of transactions in DBMS.
What does a Transaction mean in DBMS?
•Transaction in Database Management Systems (DBMS) can be defined as a set of logically
related operations.
•It is the result of a request made by the user to access the contents of the database and
perform operations on it.
•It consists of various operations and has various states in its completion journey.
•It also has some specific properties that must be followed to keep the database consistent.
Operations of Transaction

A user can make different types of requests to access and modify the contents of a database. So, we have different types of operations relating to a transaction. They
are discussed as follows:

i) Read(X)

• A read operation is used to read the value of X from the database and store it in a buffer in the main memory for further actions such as displaying that value.

• Such an operation is performed when a user wishes just to see any content of the database and not make any changes to it. For example, when a user wants to
check his/her account’s balance, a read operation would be performed on user’s account balance from the database.

ii) Write(X)

• A write operation is used to write the value to the database from the buffer in the main memory. For a write operation to be performed, first a read operation is
performed to bring its value in buffer, and then some changes are made to it, e.g. some set of arithmetic operations are performed on it according to the user’s request,
then to store the modified value back in the database, a write operation is performed.

• For example, when a user requests to withdraw some money from his account, his account balance is fetched from the database using a read operation, then the
amount to be deducted from the account is subtracted from this value, and then the obtained value is stored back in the database using a write operation.

iii) Commit

• This operation in transactions is used to maintain integrity in the database. Due to some failure of power, hardware, or software, etc., a transaction might get
interrupted before all its operations are completed. This may cause ambiguity in the database, i.e. it might get inconsistent before and after the transaction.

• To ensure that further operations of any other transaction are performed only after work of the current transaction is done, a commit operation is performed to the
changes made by a transaction permanently to the database.

iv) Rollback

• This operation is performed to bring the database to the last saved state when any transaction is interrupted in between due to any power, hardware, or software
failure.

• In simple words, it can be said that a rollback operation does undo the operations of transactions that were performed before its interruption to achieve a safe state of
the database and avoid any kind of ambiguity or inconsistency.
Transaction Property(ACID)
ACID Properties:
•Atomicity: Ensures that all operations within a transaction are completed; if one fails, the entire
transaction fails.
•Consistency: Ensures that the database moves from one valid state to another, maintaining data
integrity.
•Isolation: Ensures that transactions occur independently and transparently from each other.
•Durability: Guarantees that once a transaction has been committed, it will remain in the system
even in the event of a crash
STATE OF TRANSACTION
1. Active State – When the instructions of the transaction are running then the transaction
is in active state. If all the ‘read and write’ operations are performed without any error then
it goes to the “partially committed state”; if any instruction fails, it goes to the “failed state”.
2. Partially Committed – After completion of all the read and write operation the changes
are made in main memory or local buffer. If the changes are made permanent on the
DataBase then the state will change to “committed state” and in case of failure it will go to
the “failed state”.
3. Failed State – When any instruction of the transaction fails, it goes to the “failed state”
or if failure occurs in making a permanent change of data on Database.
4. Aborted State – After having any type of failure the transaction goes from “failed state”
to “aborted state” and since in previous states, the changes are only made to local buffer or
main memory and hence these changes are deleted or rolled-back.
5.Committed State – It is the state when the changes are made permanent on the Data
Base and the transaction is complete and therefore terminated in the “terminated state”.
6.Terminated State – If there isn’t any roll-back or the transaction comes from the
“committed state”, then the system is consistent and ready for new transaction and the old
transaction is terminated.
DATABASE BACKUP
A database backup in SQL or a database management system (DBMS) is a process of creating a
copy of the database data and schema to safeguard against data loss, corruption, or disasters.
Backups allow you to restore the database to a previous state in case of failures, accidental
deletions, or other issues.
TYPES OF DATABASE 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.
There are two methods to perform a physical backup :
1. Operating system utilities
2. Recovery manager

This type of backup is useful when the user needs to restore the complete database in
a short period. It is beneficial to provide details of transactions and changes made in
databases. It is considered the foundation of the recovery mechanism. This form of
backup has the drawback of slowing down database operations.
Advantages:
•It is useful when the user needs to restore the complete database in a short period.
•They provide details of transactions and changes made in databases.
Disadvantage:
•This slows down database operations.
Logical Backup:
It contains logical data which is retrieved from the database. It contains a view, procedure,
function, and table. 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. Every week, complete logical
backups should be performed. Logical backups are used as a supplement to a physical
backup.
Advantages:
•This is useful when the user needs to restore the complete database to the last time.
•It was more complex and provides granular recovery capabilities.
Disadvantages:
•Critical for recovery of special components.
•less secure compared to physical backup.
•It only provides structural details.
Physical Backup Logical Backup

Physical database backups are backups of physical files that are Logical database backups are backups of logical files that are
used to store and recover databases. retrieved from the database.

It contains data files, control files, and archived redo logs. It contains a view, a procedure, a function, and a table.

It copies data files when data is running or stopped. Using the EXPORT keyword Logical backup is done

A user needs to restore the complete database in a short period This is useful when users want to restore or transfer a copy of the
of time. database to a different location.

More secure than logical backup. Less secure as compared to Physical backup
TYPES OF FAILURES

OR DISK failure
1. Transaction failure
The transaction failure occurs when it fails to execute or when it reaches a point
from where it can't go any further. If a few transaction or process is hurt, then this is
called as transaction failure.
Reasons for a transaction failure could be -
Logical errors: If a transaction cannot complete due to some code error or an
internal error condition, then the logical error occurs.
Syntax error: It occurs where the DBMS itself terminates an active transaction
because the database system is not able to execute it. For example, The system
aborts an active transaction, in case of deadlock or resource unavailability.
2. System Crash
• System failure can occur due to power failure or other hardware or software
failure. Example: Operating system error.
• Fail-stop assumption: In the system crash, non-volatile storage is assumed
not to be corrupted.
3. Disk Failure
• It occurs where hard-disk drives or storage drives used to fail frequently. It was
a common problem in the early days of technology evolution.
• Disk failure occurs due to the formation of bad sectors, disk head crash, and
unreachability to the disk or any other failure, which destroy all or part of disk
storage.
CAUSES OF FAILURES
1. Hardware Failures

• Disk Failures: Mechanical issues or wear and tear can lead to disk crashes, causing data loss.

• Power Outages: Sudden loss of power can disrupt ongoing transactions and corrupt data files.

• Network Issues: Problems with network hardware or connectivity can lead to communication failures between the DBMS and clients.

2. Software Bugs

• DBMS Bugs: Errors in the database software itself can lead to crashes, incorrect data handling, or performance degradation.

• Operating System Bugs: Issues with the underlying OS can impact the DBMS’s operation and stability.

3. Human Errors

• Incorrect Commands: Mistakenly executing wrong SQL commands (e.g., DELETE instead of SELECT) can lead to data loss.

• Misconfigurations: Errors in configuration settings can affect performance, security, and stability.

4. Data Corruption

• Improper Shutdowns: Unexpected shutdowns during write operations can corrupt data files.

• Virus or Malware Attacks: Malicious software can alter or destroy database files.

5. Concurrency Issues

• Deadlocks: Multiple transactions waiting for each other to release resources can halt processing.

• Race Conditions: Improper handling of simultaneous transactions can lead to data anomalies.
6. Resource Exhaustion
•Memory Leaks: Applications that do not release memory can cause the DBMS to run out of resources, leading to
failures.
•Disk Space Exhaustion: Running out of disk space can prevent further data insertion or updates.
7. Network Failures
•Latency: High latency in network connections can slow down database access and processing.
•Disconnections: Temporary loss of connectivity can interrupt ongoing transactions.
8. Security Vulnerabilities
•Unauthorized Access: Breaches can lead to data theft or corruption.
•SQL Injection: Malicious input can manipulate or destroy data.
9. Natural Disasters
•Environmental Factors: Events like floods, earthquakes, or fires can physically damage the infrastructure hosting the
DBMS.
10. External Dependencies
•Third-Party Applications: Issues with integrated applications or services can affect the DBMS’s performance and
stability.
Recognizing these causes helps in implementing preventive measures and robust recovery strategies to maintain
database integrity and availability.
DATABASE RECOVERY
DATABASE RECOVERY TECHNIQUES

1)UNDOING
2)REDO LOG AND ROLLING FORWARD
3)ROLLBACK SEGMENT AND ROLLING BACK
OVERVIEW OF
ADVANCED DATABASE
CONCEPT
1)DATA WAREHOUSE
A data warehouse is a centralized repository designed to store and analyze large volumes of
structured and unstructured data from various sources. It enables organizations to consolidate
data from different systems for reporting, analysis, and business intelligence. Key features
include:ETL Process: Extract, Transform, Load processes that prepare data for analysis.Data
Modeling: Organizes data into schemas, often using star or snowflake designs.OLAP: Supports
Online Analytical Processing for complex queries and analytics.Historical Data Storage:
Maintains historical data for trend analysis and reporting.Common tools and platforms include
Amazon Redshift, Google BigQuery, and Snowflake. Data warehouses help businesses make
informed decisions by providing a comprehensive view of their data.
2)DATA LAKE
A data lake is a central location that holds a large amount of data in its native, raw
format. Compared to a hierarchical data warehouse, which stores data in files or
folders, a data lake uses a flat architecture and object storage to store the data.
Object storage stores data with metadata tags and a unique identifier, which makes
it easier to locate and retrieve data across regions, and improves performance. By
leveraging inexpensive object storage and open formats, data lakes enable many
applications to take advantage of the data.
3)DATA MINING
Data mining in the context of Database Management Systems (DBMS) involves extracting useful patterns and information from large databases. Here’s how data mining integrates with DBMS:

Key Concepts

1.Data Warehousing: Data mining often relies on data warehouses, which consolidate data from various sources into a single repository. This structured data is easier to analyze.

2.Data Preparation: In DBMS, data must be cleaned and preprocessed. This includes removing duplicates, handling missing values, and transforming data into suitable formats.

3.Data Models: DBMS supports various data models (relational, NoSQL, etc.), which influence how data is stored, accessed, and mined. For instance, relational databases use SQL queries for data
retrieval.

4.Mining Techniques: Common data mining techniques applicable within DBMS include:
1. Classification: Assigning categories to data points (e.g., spam detection).
2. Clustering: Grouping similar data points (e.g., customer segmentation).
3. Association Rule Mining: Discovering relationships between variables (e.g., market basket analysis).
4. Anomaly Detection: Identifying outliers or unusual patterns (e.g., fraud detection).

5.Integration with BI Tools: Many DBMS offer integration with Business Intelligence (BI) tools, allowing users to visualize data mining results and generate reports.

Applications

• Customer Relationship Management (CRM): Analyzing customer data to improve marketing strategies and enhance customer satisfaction.

• Fraud Detection: Monitoring transactions in real-time to identify suspicious activities.

• Recommendation Systems: Providing personalized recommendations based on user behavior and preferences.
4) BIG DATA
Big Data in the context of Database Management Systems (DBMS) refers to the management,
storage, and analysis of extremely large and complex data sets that traditional DBMS technologies
may struggle to handle efficiently. Here’s an overview of how Big Data intersects with DBMS:
Key Characteristics of Big Data
1.Volume: Large amounts of data generated from various sources (e.g., social media, sensors,
transactions).
2.Velocity: The speed at which data is generated and processed, often in real time.
3.Variety: The different types of data (structured, semi-structured, unstructured) that can come from
various sources.
4.Veracity: The quality and reliability of the data, which can vary significantly.
5.Value: The insights that can be derived from analyzing Big Data.
TYPES BIG DATA
Structured data
Structured data has certain predefined organizational properties and is present in structured or
tabular schema, making it easier to analyze and sort. In addition, thanks to its predefined nature,
each field is discrete and can be accessed separately or jointly along with data from other fields. This
makes structured data extremely valuable, making it possible to collect data from various locations in
the database quickly.
Unstructured data
Unstructured data entails information with no predefined conceptual definitions and is not easily
interpreted or analyzed by standard databases or data models. Unstructured data accounts for the
majority of big data and comprises information such as dates, numbers, and facts. Big data examples
of this type include video and audio files, mobile activity, satellite imagery, and No-SQL databases, to
name a few. Photos we upload on Facebook or Instagram and videos that we watch on YouTube or
any other platform contribute to the growing pile of unstructured data.
Semi-structured data
Semi-structured data is a hybrid of structured and unstructured data. This means that it inherits a
few characteristics of structured data but nonetheless contains information that fails to have a
definite structure and does not conform with relational databases or formal structures of data
models. For instance, JSON and XML are typical examples of semi-structured data.
MONGODB
MongoDB is a widely used NoSQL database that is designed to store, manage, and retrieve data in a flexible and scalable way. Here are some key aspects
of MongoDB:
Key Features
1.Document-Oriented: MongoDB stores data in flexible, JSON-like documents (BSON format), allowing for varied structures within the same collection.
2.Schema Flexibility: Unlike traditional relational databases, MongoDB does not require a fixed schema, enabling you to modify the data structure easily as
your application evolves.
3.Scalability: It supports horizontal scaling through sharding, which distributes data across multiple servers, making it suitable for handling large volumes of
data.
4.Rich Query Language: MongoDB provides a powerful query language that supports complex queries, including filtering, sorting, and aggregation.
5.Indexes: You can create various types of indexes to enhance query performance, improving search speed.
6.Replication: MongoDB supports replica sets, which maintain copies of data across multiple servers for redundancy and high availability.
7.Aggregation Framework: This allows for complex data processing and transformations, enabling advanced analytics directly within the database.
Use Cases
• Web Applications: Ideal for applications that require rapid development and deployment.
• Real-Time Analytics: Useful for analyzing streaming data and generating insights.
• Content Management: Suitable for storing diverse content types and structures.
• Internet of Things (IoT): Handles large volumes of data from connected devices.
Advantages
• Flexibility and Scalability: Easily adapt to changing data requirements and scale with growing data loads.
• Developer-Friendly: The document model is intuitive for developers, especially those familiar with JSON.
DYNAMODB
Amazon DynamoDB is a fully managed NoSQL database service provided by Amazon Web Services (AWS). It is designed to handle high-traffic applications, offering low-latency
performance at scale. Here are the key features and concepts associated with DynamoDB:

Key Features

1.Managed Service: DynamoDB is a fully managed service, meaning AWS takes care of hardware provisioning, setup, configuration, and scaling.

2.Scalability: It can automatically scale up or down based on your application's traffic, allowing you to handle large volumes of read and write operations without manual intervention.

3.Performance: Offers single-digit millisecond response times, making it suitable for applications that require real-time data access.

4.Flexible Data Model: Supports both key-value and document data models, allowing you to store structured and unstructured data.

5.Global Tables: Enables cross-region replication, allowing you to deploy applications that require high availability and disaster recovery across multiple AWS regions.

6.Built-in Security: Provides features like encryption at rest, fine-grained access control through AWS Identity and Access Management (IAM), and VPC (Virtual Private Cloud) support.

7.Event-Driven Architecture: Integrates with AWS Lambda, enabling you to trigger functions based on changes in the data (e.g., updates or inserts).

Data Structure

• Tables: The primary structure where data is stored. Each table has a primary key that uniquely identifies each item.

• Items: Individual records in a table, similar to rows in relational databases.

• Attributes: Key-value pairs that define the properties of an item.

Use Cases

• Web and Mobile Applications: Ideal for applications with unpredictable traffic and variable data access patterns.

• Gaming: Supports real-time leaderboards, player profiles, and game state management.

• IoT Applications: Handles data from millions of devices and sensors efficiently.

• E-Commerce: Manages product catalogs, user sessions, and shopping carts.

You might also like