Database (2)
Database (2)
1. Database
2. Data
3. Information
4. Entities
Objects or things in the real world that are distinguishable from each other and
are represented in a database. Example: A student, employee, or product.
5. Attributes/Field
1|Page
6. Records
7. Table
8. Database Schema
Software that provides tools and functionalities to create, manage, retrieve, and
update data in a database. Example: MySQL, MongoDB, or Oracle DB.
Applications of Databases
Databases are widely used across industries to manage, organize, and analyze
data. Some common applications include:
2|Page
1. Banking and Finance
o Managing customer accounts, transactions, and loans.
o ATM operations and online banking systems.
o Fraud detection using data analysis.
2. E-Commerce
o Storing product information, inventory, and customer orders.
o Managing user profiles and preferences.
o Supporting search and recommendation systems.
3. Healthcare
o Maintaining electronic health records (EHRs).
o Managing patient data, appointments, and prescriptions.
o Supporting medical research with data analysis.
4. Education
o Storing student records, course information, and grades.
o Supporting e-learning platforms and online exams.
o Managing library systems and resources.
5. Retail and Inventory Management
o Tracking stock levels, sales, and purchases.
o Managing customer loyalty programs.
o Supporting supply chain operations.
6. Telecommunications
o Managing customer accounts and billing.
o Tracking call records and data usage.
o Supporting network optimization and troubleshooting.
7. Government and Public Services
o Maintaining citizen records, including tax and social security
information.
o Managing public projects and budgets.
o Supporting law enforcement with crime data.
3|Page
8. Travel and Hospitality
o Managing reservations for flights, hotels, and car rentals.
o Tracking customer preferences for personalized services.
o Supporting travel planning and logistics.
9. Social Media and Entertainment
o Storing user-generated content and activity logs.
o Managing streaming media libraries.
o Supporting recommendation algorithms.
10. Research and Development
o Storing and analyzing experimental data.
o Managing collaborative projects and resources.
Advantages of Databases
1. Data Organization
o Centralized storage allows better organization and easy access to
data.
2. Data Integrity
o Ensures accuracy and consistency through constraints and rules.
3. Data Security
o Allows user access control and encryption to protect sensitive
information.
4. Data Sharing
o Facilitates sharing data among multiple users and applications.
5. Scalability
o Can handle growing amounts of data and user requests efficiently.
6. Data Recovery
o Supports backup and recovery mechanisms to prevent data loss.
7. Query and Analysis
o Enables complex queries and analytical insights for decision-
making.
4|Page
8. Reduced Redundancy
o Minimizes duplication through normalization techniques.
Disadvantages of Databases
1. Complexity
o Requires skilled personnel for design, maintenance, and
management.
2. Cost
o High initial costs for hardware, software, and training.
3. Performance Issues
o May experience slowdowns with poorly optimized queries or high
loads.
4. Data Breach Risks
o Centralized systems are attractive targets for cyberattacks.
5. Maintenance Overhead
o Regular updates and backups require time and resources.
6. Dependency
o Over-reliance on databases can create bottlenecks if systems fail.
7. Hardware and Software Requirements
o Requires significant infrastructure to run efficiently.
1. Relational Database
5|Page
Key Features:
o Uses primary keys to uniquely identify rows.
o Establishes relationships between tables using foreign keys.
o Supports Structured Query Language (SQL) for data
manipulation.
Examples: MySQL, PostgreSQL, Oracle Database.
2. Hierarchical Database
3. Network Database
6|Page
4. Object-Oriented Model
7|Page
2. One-to-Many (1:N) Relationship
8|Page
Implementation:
o Relational Databases: Use a join table (junction table) with foreign
keys pointing to both tables.
Example: A table named student_courses with fields like
student_id and course_id.
o NoSQL Databases:
Embed references to the related entities in each document (if
relationships are simple).
Use separate collections to manage associations (for complex
or large datasets).
A data type is a classification that specifies which type of value a variable can
hold in a programming language or database. It defines the kind of data that
can be stored in a variable or field and the operations that can be performed on
it.
9|Page
o When to Use: Use character data types for any fields that store
letters, symbols, or alphanumeric data.
2. Number Data Type:
o Purpose: Used to store numerical values.
o Examples:
INT: Integer, for whole numbers (e.g., INT for ages or
counts).
FLOAT/REAL: Floating-point numbers, for decimals (e.g.,
FLOAT for price or temperature).
DECIMAL/NUMERIC: Exact numeric data types for precise
values, often used for financial data (e.g., DECIMAL(10, 2)
for storing prices with two decimal places).
o When to Use: Use number data types for any field that involves
mathematical calculations, counting, or precise financial data.
3. Date Data Type:
o Purpose: Used to store date and time values.
o Examples:
DATE: Stores a date in the format YYYY-MM-DD (e.g., DATE
for birthdates or event dates).
TIME: Stores a time value (e.g., TIME for storing a
timestamp).
DATETIME/TIMESTAMP: Stores both date and time (e.g.,
DATETIME for logging creation or modification times).
o When to Use: Use date data types when working with any kind of
time-based information, such as scheduling, events, or historical
records.
10 | P a g e
Description of data dictionary
11 | P a g e
5. Constraints:
o Rules that restrict the types of values a field can hold. Common
constraints include NOT NULL, UNIQUE, PRIMARY KEY, and
FOREIGN KEY.
6. Relationships:
o Describes how data elements in one table relate to data elements
in another table, often represented by foreign keys.
7. Descriptions:
o A textual explanation of each data element or table, providing
clarity about its purpose and meaning. This ensures everyone
using the data dictionary understands the context of the data.
8. Indexes:
o Information about any indexing used in the database to improve
the performance of queries. This can include the type of index,
columns indexed, and the indexing method.
9. Validation Rules:
o Specifies the criteria that data must meet in order to be considered
valid. For example, an email field may have a rule validating the
presence of "@" and a domain name.
10. Security and Access Control:
o Information regarding who has access to specific data elements or
tables, and any restrictions based on user roles.
11. Example Values:
o A set of sample or typical values that the field can have, to aid in
understanding the kinds of data expected.
12 | P a g e
Identification of database requirements
1. Functional Requirement:
Example: The system must allow users to input customer data and retrieve
customer order histories.
2. Non-functional Requirement:
Example: The database should support at least 100 concurrent users and ensure
no downtime longer than 2 hours per year.
There are several methods used to collect data about the system’s
requirements. These methods help gather both functional and non-functional
requirements from stakeholders.
1. Interview:
2. Documentation:
14 | P a g e
Example: Analyzing existing database schema or business process
documentation to understand the data flow.
3. Questionnaire:
Example: A questionnaire asking users about their database usage habits and
requirements for specific features.
4. Observation:
Observation involves watching users interact with the current system or their
workflow to understand their needs. It can provide insights into how the
database is used in practice and where improvements are needed.
Conclusion
15 | P a g e
LEARNING OUTCOME 2: DESIGN DATABASE
1. Physical Schema:
o Defines how the data is stored physically on the hardware (e.g.,
storage devices, file systems).
o Involves the specification of file formats, indexing techniques, and
the way data is actually stored in memory.
2. Logical Schema:
o Represents the logical view of the data, abstracting away physical
storage concerns.
o Defines tables, relationships, constraints, views, and data types.
o It is closer to the user's needs, as it represents the organization of
data elements without the physical storage details.
3. View Schema:
o Describes how users or applications will see the data. It can be
thought of as a virtual schema.
o Provides a customized and simplified representation of the data,
often used for security or performance reasons.
16 | P a g e
o The view schema doesn’t include the actual data but refers to how
it should appear to end users or applications.
Data abstraction allows users and applications to interact with data without
being concerned with its internal workings. The three main levels of data
abstraction are:
1. Physical Level:
o The lowest level of abstraction, dealing with how data is stored on
physical storage devices.
o Concerned with file organization, indexing methods, and data
compression techniques.
2. Logical Level:
o Focuses on the structure of the data and its relationships.
o Describes the logical view of data in terms of tables, views, and
entities.
3. View Level:
o The highest level of abstraction, tailored to the specific needs of
users or applications.
o Hides unnecessary details and provides customized access to the
data.
Data independence refers to the capacity to change the schema at one level of
the database system without affecting the schema at the next higher level.
There are two types of data independence:
17 | P a g e
1. Physical Data Independence:
o Refers to the ability to change the physical schema (such as
reorganizing the database on disk, changing file structures, or
altering storage formats) without affecting the logical schema or
application programs.
o It is considered one of the most important forms of data
independence because it allows the database to evolve without
impacting its operation.
2. Logical Data Independence:
o Refers to the ability to change the logical schema (such as adding
new tables or modifying relationships between tables) without
affecting the external schema or user views.
o Logical data independence is more difficult to achieve than
physical data independence because changes at the logical level
are often more complex and can impact the way applications
interact with the database.
When designing a conceptual database schema, the primary goal is to map out
how data will be structured and related in a database. Here's a breakdown of
the process:
18 | P a g e
Description of Conceptual Database Schema:
A conceptual database schema outlines the overall structure and the key
entities of the database. It serves as an abstract, high-level design before
translating it into a physical schema in a specific DBMS. It focuses on what
data will be stored rather than how it will be stored.
This schema helps identify the entities involved, their attributes, and the
relationships between them without delving into the specifics of how data will
be implemented.
Description of ERD:
19 | P a g e
Components of ERD:
Define Relationships:
One-to-One (1:1): Each entity in the relationship will have one related
entity.
o Example: A customer can have one loyalty card.
One-to-Many (1:M): One entity is related to many instances of another
entity.
o Example: A customer can place many orders.
Many-to-Many (M:N): Multiple instances of an entity are related to
multiple instances of another entity.
20 | P a g e
o Example: A student can enroll in many courses, and a course can
have many students.
Create an ERD:
Example ERD:
21 | P a g e
Tools:
1. Entities: The objects or concepts that will hold data. These are typically
represented as tables in the relational model.
2. Attributes: The properties or fields of the entities, represented as
columns in the tables.
3. Relationships: Associations between entities. In relational databases,
these are usually modeled as foreign keys linking tables.
4. Constraints: Rules applied to columns or tables to ensure the integrity
and correctness of the data. Constraints include primary keys, foreign
keys, and other data rules like NOT NULL and UNIQUE.
22 | P a g e
Table Constraints:
Table constraints ensure the integrity of the data within the table and across
tables. Two common constraints are:
This constraint ensures that a column cannot have a NULL value. It is used to
enforce that the column must contain data for every row in the table. It is
commonly applied to columns that are critical for the identification or integrity
of the data, such as primary keys.
Example:
FirstName VARCHAR(50),
LastName VARCHAR(50),
BirthDate DATE,
);
23 | P a g e
2. UNIQUE Constraint:
The UNIQUE constraint ensures that all values in a column are different.
Unlike the primary key, which also enforces uniqueness, the UNIQUE
constraint can be applied to multiple columns in a table, and the columns can
contain NULL values (a column with NULL can still have unique values, but
multiple NULL values are allowed).
Example:
FirstName VARCHAR(50),
LastName VARCHAR(50),
);
3. DEFAULT Constraint:
The DEFAULT constraint provides a default value for a column when no value
is specified during an insert operation. If a user doesn't explicitly provide a
value for a column, the default value is used.
24 | P a g e
Example:
ID int,
Name varchar(255),
);
In this case, if the age is not provided while inserting a record, it will
default to 30.
4. CHECK Constraint:
The CHECK constraint ensures that the values in a column satisfy a specific
condition. It can be used to limit the range of values or enforce other rules.
Example:
ID int,
);
Here, the CHECK constraint ensures that only ages 18 and above are allowed.
25 | P a g e
Example:
Name varchar(255)
);
In this case, the ID column serves as the primary key, and each record in the
Employees table must have a unique value for ID.
Example:
EmployeeID int,
);
Here, the EmployeeID in the Orders table refers to the ID in the Employees
table, ensuring that any employee listed in the Orders table exists in the
Employees table.
26 | P a g e
Convert Conceptual Database Schema to Logical Database Schema:
Example of conversion:
Name varchar(255),
Age int
);
27 | P a g e
CREATE TABLE Orders (
EmployeeID int,
);
Optimization of database
Data Normalization:
28 | P a g e
2. Second Normal Form (2NF):
o Achieved by ensuring that the database is in 1NF.
o All non-key attributes are fully dependent on the primary key
(eliminating partial dependencies).
o If the table has a composite primary key (more than one column),
non-key columns must depend on the entire composite key.
Example: In a table with orders and products, the product details should
not depend on the order ID alone (a partial dependency), but on the
combination of order ID and product ID.
Indexing:
B-tree Indexes: Most common index type, used for equality and range
queries.
Hash Indexes: Used for exact match queries, where the data can be
directly mapped using a hash function.
29 | P a g e
Composite Indexes: Indexes that involve multiple columns, useful for
queries that filter on more than one column.
Full-Text Indexes: Used for searching textual data efficiently.
Indexes speed up read operations but can slow down write operations
(insert, update, delete) because the index must also be updated.
Not all queries benefit from indexing. You should only create indexes on
columns that are frequently used in WHERE, JOIN, or ORDER BY
clauses.
Over-indexing can lead to performance degradation, so it’s important to
strike the right balance.
Description of DBMS
30 | P a g e
SQL Compliance: Follows ANSI SQL standards, allowing for flexibility in
query and operation.
Replication & Sharding: Supports replication for fault tolerance and
horizontal scaling.
Indexing: Offers primary, unique, and full-text indexes for query
optimization.
Security: Provides access control, role-based privileges, and SSL
encryption.
1. Install MySQL:
o Download MySQL from the official website.
o Follow installation steps suitable for your OS.
2. Set Up MySQL Server:
o Configure the MySQL server instance, ensuring it uses a secure
root password.
3. Install MySQL Workbench (Optional):
o MySQL Workbench simplifies database management with a
graphical interface.
4. Create a Database:
USE my_database;
31 | P a g e
GRANT ALL PRIVILEGES ON my_database.* TO 'db_user'@'localhost';
FLUSH PRIVILEGES;
Steps to Convert:
a. Define Tables:
Example:
DepartmentID INT,
32 | P a g e
b. Define Relationships:
Example:
EmployeeID INT,
ProjectID INT,
);
c. Apply Indexes:
d. Normalize or Denormalize:
33 | P a g e
e. Partition Data (Optional):
);
) ENGINE=InnoDB;
34 | P a g e
DepartmentID INT AUTO_INCREMENT PRIMARY KEY,
);
DepartmentID INT,
);
);
EmployeeID INT,
ProjectID INT,
35 | P a g e
FOREIGN KEY (ProjectID) REFERENCES Project(ProjectID)
);
Description to SQL
Introduction to SQL
SQL Sub-Languages
36 | P a g e
1. DDL (Data Definition Language):
o Used to define and manage database structures such as tables,
indexes, and schemas.
o Examples: CREATE, ALTER, DROP.
2. DML (Data Manipulation Language):
o Used to manage data within database tables.
o Examples: SELECT, INSERT, UPDATE, DELETE.
3. DCL (Data Control Language):
o Controls access to data in a database.
o Examples: GRANT, REVOKE.
4. TCL (Transaction Control Language):
o Manages database transactions to ensure data integrity.
o Examples: COMMIT, ROLLBACK, SAVEPOINT.
5. DQL (Data Query Language):
o Used to query and retrieve data.
o Example: SELECT (often considered part of DML).
SQL Operators
37 | P a g e
1. SQL Arithmetic Operators
+ Addition SELECT 10 + 5;
- Subtraction SELECT 10 - 5;
* Multiplication SELECT 10 * 5;
/ Division SELECT 10 / 5;
` ` Bitwise OR
38 | P a g e
3. SQL Compound Operators
39 | P a g e
Application of DDL commands
CREATE
Used to create new database objects like databases, tables, and constraints.
Examples:
Database:
Table:
name VARCHAR(100),
age INT,
department VARCHAR(50)
);
Creates a table named employees with columns id, name, age, and department.
40 | P a g e
CREATE TABLE students (
);
Adds constraints like PRIMARY KEY, UNIQUE, and CHECK during table
creation.
ALTER TABLE
Examples:
Add a column:
Drop a column:
Modify a column:
41 | P a g e
DROP
Used to delete entire database objects like databases or tables. Warning: This
action is irreversible.
Examples:
Database:
Table:
TRUNCATE TABLE
Used to delete all rows from a table, but retains the table structure for future
use. It's faster than DELETE as it does not log individual row deletions.
Example:
Removes all data from the employees table but keeps the structure intact.
42 | P a g e
MODIFY
Example:
Summary Table:
The Data Manipulation Language (DML) commands are used to manage and
manipulate data within database objects like tables. Here's an overview of the
listed DML commands and their application:
43 | P a g e
INSERT
Example:
UPDATE
UPDATE table_name
WHERE condition;
Example:
UPDATE employees
WHERE id = 101;
44 | P a g e
DELETE
Example:
Note: Without a WHERE clause, all records in the table will be deleted.
CALL
CALL procedure_name(parameters);
Example:
EXPLAIN CALL
Purpose: Analyze and display the execution plan for a stored procedure
call.
Usage: Helps in debugging and performance optimization.
Syntax:
Example:
Example:
Summary of Usage
SELECT Command
The SELECT statement is the core of DQL, used to query and retrieve data from
a database.
46 | P a g e
Syntax:
SELECT column1, column2, ...
FROM table_name;
Example:
FROM users;
Examples:
FROM users;
47 | P a g e
SELECT SUM(salary) AS total_salary
FROM employees;
FROM grades;
3. SQL Clauses
Common Clauses:
Examples:
FROM users
48 | P a g e
2. Group employees by department and count them:
FROM employees
GROUP BY department;
FROM employees
GROUP BY department
FROM employees
49 | P a g e
GRANT Command
Syntax:
GRANT <privilege_list> ON <object_name> TO <user_or_role> [WITH GRANT
OPTION];
Examples:
3. Grant INSERT and UPDATE privileges on the orders table to jane with
the ability to grant these permissions to others:
50 | P a g e
REVOKE Command
Syntax:
REVOKE <privilege_list> ON <object_name> FROM <user_or_role>;
Examples:
1. Revoke SELECT privilege on the employees table from the user john:
2. Revoke all privileges on the sales table from the role manager:
3. Revoke INSERT and UPDATE privileges on the orders table from jane:
51 | P a g e
1. COMMIT
Purpose: Saves all the changes made during the current transaction
permanently in the database.
When to Use: Use after completing a set of operations that should be
permanently saved.
Example:
BEGIN TRANSACTION;
COMMIT;
Explanation: Deducts $100 from one account and adds it to another. COMMIT
makes these changes permanent.
2. SAVEPOINT
Purpose: Creates a point within a transaction that can be rolled back to,
without affecting the entire transaction.
When to Use: Use when multiple steps need checkpointing within a
single transaction.
Example:
BEGIN TRANSACTION;
SAVEPOINT deduct_amount;
ROLLBACK TO deduct_amount;
52 | P a g e
COMMIT;
Explanation: Deducts $50 and saves the state using SAVEPOINT. If there’s an
issue with the second update, we can roll back to deduct_amount.
3. ROLLBACK
Example:
BEGIN TRANSACTION;
ROLLBACK;
4. SET TRANSACTION
53 | P a g e
Example:
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
BEGIN TRANSACTION;
COMMIT;
5. SET CONSTRAINTS
Example:
SET CONSTRAINTS ALL DEFERRED;
BEGIN TRANSACTION;
COMMIT;
54 | P a g e
Summary Table of Usage
Command Purpose
SET
Enables or defers constraint checking for the transaction.
CONSTRAINTS
55 | P a g e
LEARNING OUTCOME 4: IMPLEMENT DATABASE SECURITY
56 | P a g e
Data Access Control
Data access control refers to the measures used to restrict and regulate who
can view or manipulate data within a database. Access control ensures that
only authorized users have the required permissions to interact with the
database based on predefined policies.
Access control policies are frameworks defining how access is granted and
regulated in a database.
57 | P a g e
Data Classifications
Roles:
Roles are predefined sets of permissions that are assigned to users or groups
based on their job functions.
Permissions:
Permissions define the specific actions a role or user can perform on a
resource, such as:
58 | P a g e
Authentication
Task: Determine the users who will need access to the system and the
type of accounts required (e.g., admin, guest, regular users).
Key Actions:
o Define user roles and permissions.
o Document user requirements and security policies.
o Use tools like a directory service (e.g., Active Directory) or a
database for account storage.
Create Privileges
59 | P a g e
Configure the Authentication System
Task: Set up a secure and reliable system for verifying user identities.
Key Actions:
o Choose an authentication method:
Password-based
Multi-factor authentication (MFA)
Single Sign-On (SSO)
Biometrics
o Integrate with external providers if needed (e.g., OAuth, OpenID
Connect).
o Configure password policies, session timeouts, and account
lockout policies.
Task: Verify that the system works as intended and addresses security
concerns.
Key Actions:
o Conduct unit and integration tests for login, logout, and session
management.
o Test for edge cases, such as invalid credentials and expired tokens.
o Perform penetration testing to identify vulnerabilities.
o Ensure compliance with standards like OWASP ASVS.
60 | P a g e
o Regularly update the system to patch vulnerabilities.
o Periodically review user roles and privileges to ensure they remain
appropriate.
Authorization
Create Roles
Define roles: Determine the types of users in your system and what kind
of access they need. Examples of roles could be "Admin," "Editor,"
"Viewer," etc.
Set permissions: Define what each role can do, such as read, write,
delete, or modify resources within the system.
Assigning roles: After roles are created, you can assign them to users.
This can often be done through a user management interface or
command-line tools.
61 | P a g e
User mapping: Ensure that each user is mapped to the appropriate role
based on their responsibilities or job function.
Verify access controls: Test that each role has the expected
permissions. Ensure that users with certain roles can access only the
resources they should.
Check role hierarchy: If roles have any hierarchical structure (e.g., an
Admin role inherits the permissions of an Editor role), test that the
inheritance works as expected.
Test unauthorized access: Ensure that users without the necessary
permissions cannot access restricted resources.
62 | P a g e
Logging
Determine What to Log: Identify key events that should be logged, such
as user logins, system errors, configuration changes, or access to
sensitive data.
Set Log Levels: Define the level of detail needed (e.g., ERROR, INFO,
DEBUG, WARN, TRACE) for different events.
Determine Storage Location: Decide whether logs should be stored
locally or in a centralized logging system (e.g., cloud-based, Syslog server,
etc.).
Compliance Requirements: Ensure that logging adheres to legal,
regulatory, or organizational standards for audit trails.
63 | P a g e
Monitor Log Data
Real-time Monitoring: Set up alerts for critical events (e.g., failed login
attempts, system crashes).
Automation: Use log monitoring tools (e.g., Splunk, ELK Stack, Graylog)
to automate the collection, parsing, and alerting of log data.
Thresholds: Define thresholds for triggering alerts, such as a certain
number of failed login attempts within a short period.
Log Parsing: Use log analysis tools to parse raw log data and extract
meaningful insights.
Pattern Detection: Identify patterns of behavior that could indicate
security incidents (e.g., unusual login times, large file downloads).
Trend Analysis: Regularly analyze trends to spot potential issues before
they escalate (e.g., repeated errors or system slowdowns).
Storage and Backup: Ensure logs are archived in a secure and reliable
storage system, such as a cloud or offline storage for long-term retention.
Data Integrity: Use hash functions to ensure that archived logs are not
tampered with.
Compliance: Follow relevant regulations on log retention (e.g., GDPR,
HIPAA) to ensure logs are kept for the required duration.
Corrective Action
64 | P a g e
Review and Improvement: After an issue has been resolved, analyze the
logs to assess the effectiveness of the corrective action and improve
monitoring and prevention strategies.
Log Review: Regularly review logs for potential new threats or
operational weaknesses and adjust logging settings as necessary.
Auditing
Data encryption is the process of converting data into a secure format that can
only be read or decrypted by someone who has the proper decryption key. It is
widely used to protect sensitive information during storage or transmission,
ensuring confidentiality, integrity, and security.
65 | P a g e
Application of Encryption Techniques
There are several encryption techniques, but the most commonly used methods
are symmetric encryption, asymmetric encryption, and hashing. Here's
how they work:
1. Symmetric Encryption
Symmetric encryption uses the same key for both encryption and decryption.
The key must be kept secret and securely shared between the sender and the
recipient. This type of encryption is faster and suitable for encrypting large
amounts of data. However, the challenge lies in securely exchanging the
encryption key.
Example algorithms:
o AES (Advanced Encryption Standard): Widely used in secure
data transmission.
o DES (Data Encryption Standard): An older encryption algorithm,
now considered weak.
o 3DES (Triple DES): An improvement over DES, using three
iterations of DES encryption.
Use cases:
o Securing data at rest (e.g., hard drive encryption).
o Protecting data in transit (e.g., VPNs, HTTPS).
2. Asymmetric Encryption
66 | P a g e
Example algorithms:
o RSA: One of the most commonly used algorithms for securing
communications, especially in digital certificates.
o ECC (Elliptic Curve Cryptography): More efficient than RSA,
often used in mobile devices.
Use cases:
o Secure email (e.g., PGP encryption).
o Digital signatures and certificates for identity verification.
3. Hashing
Example algorithms:
o SHA (Secure Hash Algorithm): Includes SHA-1, SHA-256, and
SHA-512. SHA-256 is commonly used for data integrity and in
blockchain applications.
o MD5: Though widely used, MD5 is no longer considered secure
due to vulnerabilities to collision attacks.
Use cases:
o Password storage (hashed passwords in databases).
o Verifying file integrity (checksums).
Symmetric Encryption:
o Advantages: Faster than asymmetric encryption; suitable for large
amounts of data.
67 | P a g e
o Challenges: Secure key distribution and management can be
difficult.
Asymmetric Encryption:
o Advantages: Solves the key distribution problem by using public
and private keys.
o Challenges: Slower than symmetric encryption; requires more
computational resources.
Hashing:
o Advantages: Useful for ensuring data integrity and securing
passwords.
o Challenges: Not reversible; cannot be used for
encryption/decryption.
Data backup and restore are essential practices for ensuring data security,
reliability, and availability in the event of data loss, corruption, or disaster.
Backup refers to creating a copy of the data, while restore refers to the process
of recovering data from the backup. These practices ensure that systems can
be returned to their operational state in the event of system failure, accidental
deletion, or other unforeseen issues.
Backup Methods
There are several backup methods, each with its own advantages and use
cases:
68 | P a g e
1. Full Backup
o A full backup is a complete copy of all the data at a specific point
in time.
o Advantages:
Simplest and most straightforward method.
The restore process is fast since all data is contained in one
backup set.
o Disadvantages:
Time-consuming and resource-intensive, especially for large
datasets.
Requires more storage space.
2. Differential Backup
o A differential backup includes only the changes made since the
last full backup. It saves all modifications made since the most
recent full backup, regardless of previous differential backups.
o Advantages:
Faster than a full backup because only changes since the
last full backup are included.
Faster restore compared to incremental backups, as only the
last full backup and the last differential backup are needed.
o Disadvantages:
As more changes occur, the size of the differential backup
grows, making subsequent backups larger and slower.
3. Incremental Backup
o An incremental backup only includes changes made since the last
backup, whether it was a full or incremental backup.
o Advantages:
The smallest backup size as only the most recent changes
are saved.
Saves storage space and reduces the time required to
complete the backup.
69 | P a g e
o Disadvantages:
Restoring data can be slower because multiple backups (full
+ all incremental backups since the last full) are needed for
the restore process.
Full Backup: Best for critical data and systems that need to be restored
quickly. It is typically done less frequently due to its high storage and
time costs.
Differential Backup: Used when you want faster restores than
incremental backups but without the high cost of full backups. It
balances speed and storage usage.
Incremental Backup: Ideal for environments where storage space and
backup speed are critical, and data can be restored from multiple
incremental backup sets.
Backup Schedule
70 | P a g e
Create Backup
Rollback Recovery:
71 | P a g e
Point-in-Time Recovery (PITR):
Regular testing and a clear, actionable plan will ensure that you can recover
from failures efficiently.
72 | P a g e