MySQL is one of the most popular relational database management systems. It is used to store, organize, manage, and retrieve data efficiently. MySQL is widely used in websites, web applications, business software, and many other systems.
MySQL is a Relational Database Management System (RDBMS).
It allows us to store data in tables consisting of rows and columns.
MySQL = Database Management System
A database is an organized collection of data.
For example, a student database can contain student names, mobile numbers, courses, fees, and attendance.
Student Database
↓
Students
Courses
Fees
Attendance
RDBMS stands for Relational Database Management System.
It stores data in related tables and allows relationships to be created between those tables.
MySQL is an example of an RDBMS.
SQL stands for Structured Query Language.
SQL is used to communicate with relational databases.
We use SQL commands to create databases, insert data, retrieve data, update records, and delete records.
SQL and MySQL are not the same thing.
MySQL uses SQL to perform database operations.
MySQL is commonly used in:
MySQL is commonly used as the database layer of web applications.
For example, a PHP application can connect to MySQL and store student registration, login, payment, and course information.
PHP Application
↓
MySQL
↓
Database
MySQL stores relational data inside tables.
For example:
students
id | name | course
1 | Rahul | Python
2 | Amit | Java
3 | Priya | SQL
A row represents one complete record in a table.
For example, the following is one student record:
1 | Rahul | Python
This complete line represents one row.
A column represents a particular type of information.
id
name
mobile
course
fee
Each column stores a specific type of data.
Suppose we create a database named school.
CREATE DATABASE school;
This command creates a new database called school.
After creating a database, we can select it using the USE command.
USE school;
After this command, SQL statements will operate on the selected database.
Tables are created using the CREATE TABLE statement.
CREATE TABLE students (
id INT,
name VARCHAR(100),
course VARCHAR(100)
);
The INSERT INTO statement adds records to a table.
INSERT INTO students
(id, name, course)
VALUES
(1, 'Rahul', 'Python');
The SELECT statement is used to retrieve data.
SELECT * FROM students;
The * means all columns.
The UPDATE statement modifies existing records.
UPDATE students
SET course = 'Java'
WHERE id = 1;
The WHERE condition identifies the record to update.
The DELETE statement removes records.
DELETE FROM students
WHERE id = 1;
Always use a suitable WHERE condition when deleting specific records.
MySQL is frequently used with PHP for developing database-driven websites.
For example:
PHP
↓
MySQL Connection
↓
Database
↓
Tables
HTML creates the user interface, while MySQL stores application data.
A typical application may work like this:
HTML Form
↓
PHP
↓
MySQL
↓
Stored Data
MySQL can store different types of application data such as:
MySQL operates as a database server that receives requests from applications or database tools and works with stored data.
Clients can send SQL statements to the MySQL server.
A MySQL client is a tool or application that can connect to a MySQL server.
Examples include:
MySQL Workbench is a graphical tool for working with MySQL databases.
It can be used to write SQL queries, manage databases, create tables, and work with database structures.
phpMyAdmin is a web-based tool commonly used to manage MySQL and compatible database servers.
It provides a graphical interface for creating databases, tables, queries, and records.
MySQL helps applications efficiently manage large amounts of structured data.
Database operations can include creating, reading, updating, and deleting data.
These four operations are commonly called CRUD.
CRUD represents four basic database operations:
MySQL supports these operations through SQL statements.
A student management system may contain tables such as:
students
courses
fees
attendance
payments
These tables can be related to each other to build a complete application.
Learning MySQL is useful for students and developers who want to build database-driven applications.
It is especially useful when working with technologies such as PHP, Python, Java, JavaScript, and other backend technologies.
A basic MySQL workflow can be represented as:
1. Create Database
2. Select Database
3. Create Table
4. Insert Data
5. Retrieve Data
6. Update Data
7. Delete Data
This workflow forms the foundation of many database applications.
Here is a simple complete example:
CREATE DATABASE school;
USE school;
CREATE TABLE students (
id INT,
name VARCHAR(100),
course VARCHAR(100)
);
INSERT INTO students
(id, name, course)
VALUES
(1, 'Rahul', 'Python');
SELECT * FROM students;
This example creates a database, selects it, creates a table, inserts a student record, and retrieves the stored data.
Question: What is MySQL?