MySQL is a popular open-source relational database management system (RDBMS). it is used for storing, manipulating and retrieving data in databases.
Key Concepts of MySQL:
1. Relational Database:
MySQL is a relational database, which means it organises data into tables with rows and columns. Tables can be related to each other, forming relationships.
2. Tables:
A table is a collection of data organised into rows and columns. Each table in a MySQL database has a unique name .
3. Columns:
Columns (or fields) represent the individual data elements within a table. Each column has a specific data type, such as INT (integer), VARCHAR (variable character), or DATE.
4. Rows:
Rows (or records) contain the actual data stored in the table. Each row corresponds to a unique entry or record in the table.
5. Primary Key:
A primary key is a unique identifier for each row in a table. It ensures that each record can be uniquely identified and facilitates the establishment of relationships between tables.
5. Foreign Key:
A foreign key is a field in one table that refers to the primary key in another table. It establishes a link between the two tables, creating a relationship.
SQL (Structured Query Language):
MySQL uses SQL for communication. SQL is a powerful language for managing and manipulating relational databases.
Common SQL operations include Select,Insert,Update and Delete.
Basic MySQL Commands:
1.Connecting to MySQL:
mysql -u username -p
Replace username with your MySQL username. You'll be prompted to enter the password.
2. Creating a Database:
CREATE DATABASE database_name;
3.Selecting a Database:
USE database_name;
4.Creating a Table:
CREATE TABLE table_name (
column1 datatype,
column2 datatype,
...
);
5.Inserting Data:
INSERT INTO table_name (column1, column2, ...) VALUES (value1, value2, ...);
6.Querying Data:
SELECT * FROM table_name;
7.Updating Data:
UPDATE table_name SET column1 = value1 WHERE condition;
8.Deleting Data:
DELETE FROM table_name WHERE condition;
9.Dropping a Table:
DROP TABLE table_name;
10.Dropping a Database:
DROP DATABASE database_name;
To replace database_name, table_name with your actual database and table names.