MySQL Tutorial
MySQL is a Relational Database Management System (RDBMS) that stores data in structured tables with relationships between them. It follows the relational model, meaning data is stored in rows and columns, and tables can be linked using primary keys and foreign keys.
Key Features of RDBMS (MySQL Included)
Structured Data Storage – Data is stored in tables with defined structures.
Relationships Between Tables – Tables can be linked using foreign keys.
SQL Language Support – Uses SQL for querying, inserting, updating, and deleting data.
ACID Compliance – Ensures Atomicity, Consistency, Isolation, and Durability for data integrity.
Multi-User Access – Supports multiple users accessing the database simultaneously.
Data Security – Provides authentication, user roles, and privileges.
Indexes for Fast Querying – Speeds up searches using indexes.
Scalability – Can handle small to large-scale applications.
Start Learning
✔ Easy to Use – Simple SQL queries for database management.
✔ Open-Source – Free and widely supported.
✔ Cross-Platform – Works on Windows, Linux, macOS, etc.
✔ Performance – Fast and optimized for web applications.
✔ Security – Provides user access control and encryption.
✔ Scalability – Can handle small to large datasets.
✔ Replication & Backup – Supports master-slave replication for data backup.
Let's create a relational database with two tables:
student_id |
name |
gender |
city |
age |
score |
course_id |
|
phone_number |
---|---|---|---|---|---|---|---|---|
1 |
Alice |
Female |
Delhi |
20 |
85 |
101 |
NULL |
1234567890 |
2 |
Bob |
Male |
Mumbai |
22 |
75 |
NULL |
bob@email.com |
NULL |
3 |
Charlie |
Male |
Delhi |
21 |
95 |
102 |
NULL |
NULL |
4 |
David |
Male |
Bangalore |
23 |
65 |
101 |
david@email.com |
NULL |
5 |
Eve |
Female |
Mumbai |
20 |
80 |
103 |
NULL |
NULL |
6 |
Frank |
Male |
Delhi |
22 |
90 |
103 |
NULL |
NULL |
7 |
Alice |
Female |
Mumbai |
19 |
60 |
102 |
NULL |
NULL |
The columns in the "Students" table above are: student_id, name, age, email. The table has 2 records (rows).
student_id
is the Primary Key (unique identifier for each student).course_id
is a Foreign Key, linking courses to students.The columns in the "Courses" table above are: course_id, course_name, student_id. The table has 2 records (rows).
course_id
is the Primary Key (unique identifier for each student).
course_name |
course_name |
---|---|
101 |
Math |
102 |
Science |
103 |
History |
104 |
English |
The relationship between the "Courses" table and the "Students" table is the course_id column: