DBMS_Module5
DBMS_Module5
Modelling
Database Security and Optimisation
Database Security
Database security refers to the measures and mechanisms put in place to protect databases and
their contents from unauthorized access, misuse, modification, or destruction. It involves
implementing various security controls, protocols, and best practices to ensure the confidentiality,
integrity, and availability of data stored in databases. Database security aims to prevent
unauthorized users or malicious entities from gaining access to sensitive information, tampering
with data, or disrupting database operations.
• Access Control: Regulating who can access the database and what actions they can perform.
• Data Encryption: Protecting data by encoding it into unreadable formats that can only be
decrypted by authorized users.
• Auditing and Monitoring: Tracking database activities and generating logs to detect and
investigate suspicious or unauthorized behavior.
• Authentication: Verifying the identity of users or entities accessing the database.
• Data Masking and Anonymization: Concealing sensitive data to prevent unauthorized
disclosure while maintaining usability.
Importance of Securing
Databases
Securing databases is crucial for several reasons:
• Protection of Sensitive Information: Databases often contain sensitive and
confidential data, such as personal information, financial records, intellectual property, and
trade secrets. Securing databases ensures that this information remains confidential and
protected from unauthorized access.
• Compliance Requirements: Many industries and regulatory bodies have strict data
protection and privacy regulations (e.g., GDPR, HIPAA) that mandate organizations to
implement robust security measures to safeguard sensitive data. Failure to comply with
these regulations can result in legal consequences and penalties.
• Prevention of Data Loss or Theft: Database breaches or unauthorized access can lead
to data loss, theft, or exposure, causing reputational damage, financial losses, and legal
liabilities for organizations.
• Maintaining Business Continuity: Ensuring the availability and reliability of databases
is essential for business continuity. Databases must be protected against threats such as
cyberattacks, system failures, or natural disasters that could disrupt operations.
Common Threats to Database
Security
There are various threats that pose risks to database security:
• SQL Injection: Attackers inject malicious SQL code into input fields or parameters of
database queries to manipulate or access unauthorized data.
• Unauthorized Access: This includes unauthorized users gaining access to the database
through weak authentication mechanisms, stolen credentials, or exploiting vulnerabilities.
• Data Breaches: Incidents where sensitive data is accessed, stolen, or exposed to
unauthorized parties, often resulting from security vulnerabilities or insider threats.
• Malware and Ransomware: Malicious software (malware) can infect databases, leading
to data corruption, theft, or ransomware attacks where attackers demand payment to
restore access to data.
• Insider Threats: Malicious or negligent actions by employees, contractors, or trusted
entities can compromise database security by intentionally or accidentally leaking
sensitive information or abusing privileges.
Security Considerations in
Database Design
Authentication and
Authorization
Different Types of Authentication Mechanisms
1.Password-Based Authentication: Users authenticate with a username and password.
It's widely used but vulnerable to password-guessing attacks if weak passwords are used.
2.Multi-Factor Authentication (MFA): Requires users to provide two or more forms of
identification, such as a password, security token, fingerprint, or facial recognition,
enhancing security.
3.Biometric Authentication: Uses unique biological traits like fingerprints, iris scans, or
facial recognition for authentication, offering a high level of security but requiring
specialized hardware.
• RBAC assigns roles to users based on their responsibilities and grants permissions
accordingly.
• Roles define what actions users can perform (e.g., read, write, execute) on specific
database objects (e.g., tables, views).
• Administrators manage roles and assign them to users, ensuring the least privileged
access and reducing the risk of unauthorized actions.
Data Encryption
Types of Encryption:
1.Symmetric Encryption: Uses a single key for both encryption and decryption.
Fast and suitable for large amounts of data but requires secure key management
practices.
2.Asymmetric Encryption: Uses a pair of keys (public and private) for
encryption and decryption. Slower but offers stronger security and enables
secure key exchange without sharing keys.
DELIMITER //
2. Throughput
• Definition: The number of transactions or operations processed by the database within a specific
time period (e.g., transactions per second, queries per minute).
• Importance: Higher throughput indicates the database's ability to handle a larger workload and
process multiple transactions concurrently, enhancing scalability and performance under heavy
loads.
3. CPU Utilization
• Definition: The percentage of CPU resources utilized by the database server to execute queries,
processes, and transactions.
• Importance: Monitoring CPU utilization helps identify performance bottlenecks, optimize query
execution plans, and ensure efficient resource utilization.
Key Performance Metrics
• 4. Memory Usage
• Definition: The amount of memory (RAM) consumed by the database server to store
data, execute queries, and cache frequently accessed data.
• Importance: Efficient memory usage reduces disk I/O operations, improves query
performance, and enhances overall system responsiveness.
• 5. Disk I/O Operations
• Definition: The input/output operations performed on disk storage by the database
server to read or write data.
• Importance: Monitoring disk I/O operations helps identify storage bottlenecks, optimize
data retrieval and storage mechanisms, and improve database performance.
• 6. Lock Contention
• Definition: The occurrence of lock conflicts or contention between concurrent
transactions accessing shared database resources (e.g., tables, rows).
• Importance: Managing lock contention reduces transaction conflicts, improves
concurrency, and prevents performance degradation due to locking issues.
Indexing
2. Query Rewriting:
Rewrite queries to optimize performance, such as adding WHERE clauses to use indexes
efficiently.
• Example:
• -- Original query
• SELECT COUNT(*) FROM orders WHERE status = 'pending';
• -- Rewritten query
• SELECT COUNT(*) FROM orders WHERE status = 'pending' AND order_date > '2022-01-01';
Data Modeling
Normalization vs. Denormalization
• Normalization:
• Organize data into multiple related tables to reduce redundancy and improve data
integrity.
• Follow normalization forms (1NF, 2NF, 3NF) to eliminate data anomalies.
• Denormalization:
• Combine related data into fewer tables or add redundant data for performance
optimization.
• Suitable for read-heavy operations or reporting requirements.
• Designing Efficient Data Models for Performance
• Balance normalization and denormalization based on:
• Query patterns (read vs. write operations).
• Performance requirements (query response time, data retrieval speed).
• Scalability considerations (handling large data volumes).
Caching and Buffering
Caching Strategies
1.Query Caching:
1. Cache frequently executed queries and their results to reduce database load.
2. Result Caching:
• Cache query results at the application level to avoid redundant database queries.
• Buffering Mechanisms
• Buffer Pool:
• Cache frequently accessed data pages in memory to reduce disk I/O operations.
• Write-ahead Logging (WAL):
• Stage write operations in a log buffer before committing changes to disk for
improved transaction durability and performance.
Impact of Hardware on Database Performance