Setup environment
Objective:
- To set up MySQL Database Management System
- To connect to MySQL server
- To set up Python Programming Langauge
Software:
- MySQL installer (offline version)
- Visual Studio code (VS code)
Prerequisites: Install Microsoft Visual C++ 2019 Redistributable
If you already have Microsoft Visual C++ 2019 Redistributable installed, you can skip this step and continue with the lab.
- Go to the official Microsoft page. Download VC++ Redistributables
- Download the file based on your system:
- for 64-bit VC_redist.x64.exe
- for 32-bit VC_redist.x86.exe
- Open the downloaded file and check on I agree to the license terms and conditions.
- After installation, restart your PC.
MySQL
MySQL is an open-source relational database management system (RDBMS) that uses SQL to create, manage, and query data.
Why we will use MySQL?
- Support ACID transaction properites, essential for understanding transaction management
- Uses the InnoDB transactional storage engine, which supports concurrency control and recovery mechanisms
- Flexible and easy-to-use
Installing MySQL (Offline)
- Go to the official MySQL Downloads Page
- Download the Windows (x86, 32-bit), MSI Installer (Offline version ~353.7M)
- After open the Installer Choose Custom
- Select MySQL Servers and MySQL Workbench
- Proceed through the installation wizard
- Use the default port (3306)
- Choose the Authentication Method as below
- Create a root password
- Choose Windows Service as below
- Proceed through the installation wizard untill finish
What after install MySQL?
- After installing MySQL, connect to the MySQL Server. by clicking the
+
symbol next to MySQL Connections - In the dialog box, enter a Connection name, e.g.,
Local
- Click Test Connection and enter your MySQL root password to verify the connection
- After successfully connecting to the MySQL server, create a new database called
StudentDB
:- Open
local
connection - Click Create new SQL from the top-left corner
- Write SQL commands to create the
StudentDB
database, aStudents
table, and insert sample data. - Execute the Script using Execute button ⚡
/* Name: Amira Naser Aldeein Index: 01x-xxx Department: e.g., CS */ CREATE DATABASE IF NOT EXISTS StudentDB; USE StudentDB; CREATE TABLE Students ( StudentID INT PRIMARY KEY AUTO_INCREMENT, FullName VARCHAR(100) NOT NULL, Gender ENUM('M', 'F') NOT NULL, BirthDate DATE, Department VARCHAR(100), GPA DECIMAL(3,2), CreatedAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP ); -- Sample data INSERT INTO Students (FullName, Gender, BirthDate, Department, GPA) VALUES ('Ali Ahmed', 'M', '2000-05-12', 'Computer Science', 3.45), ('Sara Hassan', 'F', '2001-07-18', 'Information Systems', 3.78), ('Omar Musa', 'M', '2002-03-25', 'Mathematics', 2.90);
Once you create the database, you will see it listed under the Schemas section on the left panel
- Open
- Now you can run SQL queries on your new database
What do we mean by Connection and Port?
A database connection is a communication link between a client application (e.g., MySQL Workbench) and the MySQL server. When an application (the client) needs to perform operations such as creating databases, running queries, or retrieving data, it establishes a connection to communicate with the server.
The port is a communication endpoint on your machine. By default, MySQL uses port 3306
to listen for incoming client requests.
In short, a connection is essential to allow your client tools or applications to interact with the MySQL server, run queries, manage data, and exchange information.
Python programming language
We will use the Python programming language to simulate the following: * Concurrency control algorithms * Database recovery techniques
Download and Install Python
- Go to the Python official website
- Download the latest stable version
- Open the installer and check
- Add Python to PATH
Download and Install VS Code
- Visit the website VS code Click on
Windows
to download VS code for Windows, as shown below
- After the download finished open the
VSCodeUserSetup
executable file, when it open selectI accept the agreement
then click onNext
- Select all the option as seen below
- Finally we are ready to install the VS code, click on
install
and wait untail the setup finish - On the Vs code, on the left-hand side, click on
extension
then in the search bar, writePython
selectPython microsoft
and click onInstall
as shown below
Alteranative way to practice:
Assignment: Install MySQL, Create a Database, and Query It
Due Date on 24/5/2025
See the requirement about the structures of the lab here
- Download and Install MySQL
- Connect to the server
- Create a New Database
- Create a Table
- Insert Data
- Query the Data
What to assign:
Take Screenshots:
- SQL code (on MySQL)
- The output of your query
- Put it all on one document