Welcome to Ed2Ti Blog.

My journey on IT is here.

Introduction to Databases [3/5]

- Posted in Trebas College by

Concurrency and Transactions in MySQL

Introduction: Concurrency and transactions are fundamental concepts in database management systems, and MySQL, as a widely used relational database, provides robust mechanisms to handle these aspects efficiently. In this article, we will explore the concepts of concurrency and transactions in the context of MySQL, understanding their importance and how they contribute to the reliability and consistency of database operations.

Concurrency in MySQL:

Concurrency in MySQL refers to the ability of the database to handle multiple transactions or queries simultaneously. In a multi-user environment, where multiple clients may be accessing and modifying data concurrently, it is crucial to ensure that the operations are executed in a manner that maintains data integrity.

  1. Isolation Levels: MySQL supports different isolation levels, such as Read Uncommitted, Read Committed, Repeatable Read, and Serializable. These levels define the visibility of changes made by one transaction to other transactions. Choosing the appropriate isolation level depends on the application's requirements for consistency and performance.

  2. Locking Mechanisms: MySQL employs various locking mechanisms to control access to data. Two main types of locks are used: shared locks and exclusive locks. Shared locks allow multiple transactions to read a resource simultaneously, while exclusive locks ensure that only one transaction can modify a resource at a time. Understanding when to use each type of lock is crucial for managing concurrency effectively.

Transactions in MySQL: A transaction is a sequence of one or more SQL statements that are executed as a single unit of work. Transactions in MySQL adhere to the ACID properties (Atomicity, Consistency, Isolation, Durability), ensuring the reliability of database operations.

  1. Atomicity: Atomicity ensures that a transaction is treated as a single, indivisible unit. Either all the operations within the transaction are executed successfully, or none of them are. If any part of the transaction fails, the entire transaction is rolled back, maintaining the consistency of the database.
  2. Consistency: Consistency ensures that a transaction brings the database from one valid state to another. Constraints and rules defined on the database schema must not be violated during the execution of a transaction.
  3. Isolation: Isolation ensures that the execution of one transaction is independent of the execution of other transactions. Isolation levels, as mentioned earlier, determine the visibility of changes made by one transaction to other concurrently executing transactions.
  4. Durability: Durability guarantees that once a transaction is committed, its changes are permanent and will survive subsequent system failures. MySQL achieves durability by ensuring that the transaction log is written to disk.

Conclusion: Concurrency and transactions play a pivotal role in ensuring the reliability and performance of database systems, and MySQL provides a robust framework for managing these aspects. By understanding the mechanisms of concurrency control, isolation levels, and transaction management, developers can build scalable and consistent applications on top of MySQL databases. Implementing best practices, such as proper indexing and monitoring, further enhances the overall efficiency of database operations.

Step 1: Install VirtualBox Download and install VirtualBox from the official website

Step 2: Download Ubuntu Server 22.04 ISO Download the Ubuntu Server 22.04 LTS ISO image from the official Ubuntu website

Step 3: Create a New Virtual Machine

  • Open VirtualBox.
  • Click on "New" to create a new virtual machine. Name and Operating System:
  • Name: Enter a name for your virtual machine (e.g., "Ubuntu Server 22.04").
  • Type: Linux. Version: Ubuntu (64-bit).
  • Memory Size: Choose an appropriate amount of RAM for your virtual machine. 2 GB is a reasonable starting point.
  • Hard Disk: Select "Create a virtual hard disk now" and click "Create."

Step 4: Configure Virtual Hard Disk Choose the hard disk file type. The default is usually fine (VDI).

Choose the storage on the physical hard disk. The default "Dynamically allocated" is recommended as it allows the virtual hard disk to grow as needed.

Set the size of the virtual hard disk. At least 25 GB is recommended for a basic installation.

Click "Create" to create the virtual hard disk.

Step 5: Attach Ubuntu Server 22.04 ISO With the newly created virtual machine selected, click on "Settings."

In the Settings window, go to "System" and uncheck the Floppy disk option.

In the same window, go to "Storage."

Under the "Controller: IDE," click on the empty disk icon under "Attributes."

Click on the disk icon next to "Optical Drive" and choose "Choose a disk file."

Locate and select the Ubuntu Server 22.04 ISO you downloaded earlier.

Click "OK" to close the Settings window.

Step 6: Install Ubuntu Server Start the virtual machine.

The system will boot from the ISO image, and the Ubuntu Server installer will load.

Follow the on-screen instructions to install Ubuntu Server. You'll need to choose the language, keyboard layout, and provide basic system information.

When prompted, choose the installation type. For simplicity, you can choose the "Guided - use entire disk" option.

Complete the installation by following the remaining prompts.

When the installation is complete, remove the ISO from the virtual optical drive to prevent booting from it again.

Reboot the virtual machine.

Step 7: Configure Ubuntu Server Log in with the username and password you created during the installation.

Update the system:

sudo apt update && sudo apt upgrade

You can now configure your Ubuntu Server according to your needs.

Congratulations! You've successfully created and installed Ubuntu Server 22.04 on VirtualBox.

Introduction to Databases [2/5]

- Posted in Trebas College by

DDL (Data Definition Language): Used for defining and managing database objects.

Key Commands:
- CREATE: Used to create database objects (e.g., tables, indexes).
- ALTER: Used to modify the structure of existing database objects.
- DROP: Used to delete database objects.

DML (Data Manipulation Language): Used for managing data within database objects.

Key Commands:
- SELECT: Retrieves data from one or more tables.
- INSERT: Adds new rows of data into a table.
- UPDATE: Modifies existing data in a table.
- DELETE: Removes rows from a table.

DCL (Data Control Language): Manages access to data within the database.

Key Commands:
- GRANT: Provides specific privileges to database users.
- REVOKE: Removes specific privileges from database users.

TCL (Transaction Control Language): Manages transactions within a database.

Key Commands:
- COMMIT: Saves changes made during the current transaction.
- ROLLBACK: Undoes changes made during the current transaction.
- SAVEPOINT: Sets a point within a transaction to which you can later roll back.

Introduction to Databases [1/5]

- Posted in Trebas College by

Objective: Equip participants with a comprehensive understanding of database fundamentals, relational and non-relational models, and essential database management skills. By the end of the course, participants should confidently navigate database systems, design simple databases, and appreciate the strategic role databases play in modern information management. The course aims to empower individuals with practical knowledge applicable to various domains, fostering a strong foundation for further database exploration.

Necessaires Downloads

  1. https://www.virtualbox.org/wiki/Downloads
  2. https://www.mysql.com/downloads/
  3. https://notepad-plus-plus.org/download/
  4. https://sourceforge.net/projects/brmodelo30/
  5. Http://staruml.io/download
  6. https://www.putty.org/
  7. https://dev.mysql.com/downloads/workbench/

Operating Systems

  1. Ubuntu 22.04 : https://ubuntu.com/download/server
  2. Windows 10 : https://www.microsoft.com/en-gb/software-download/windows10

Install Ubuntu on VirtualBox
https://www.ed2ti.com/2024/01/create-an-ubuntu-server-2204-virtual-machine-using-virtualbox

Install Mysql (Linux)

sudo apt update
sudo apt install mysql-server
sudo systemctl start mysql.service

GitHub Project

https://github.com/ed2ti/introduction_databases