MySQL Tutorial
MySQL is the most popular relational database management system. In terms of WEB applications, MySQL is one of the best RDBMS (Relational Database Management System) applications.
In this tutorial, you will quickly grasp the basics of MySQL and easily use the MySQL database.
Online testing tool:https://www.jyshare.com/front-end/7768/。
What is a database?
A database is a repository that organizes, stores, and manages data according to a data structure.
Every database has one or more different APIs for creating, accessing, managing, searching, and replicating the stored data.
We can also store data in files, but reading and writing data in files is relatively slow.
Therefore, we now use a Relational Database Management System (RDBMS) to store and manage large volumes of data. A so-called relational database is a database based on the relational model, which uses mathematical concepts and methods such as set algebra to process data in the database.
The characteristics of RDBMS (Relational Database Management System) are:
- 1. Data appears in the form of tables
- 2. Each row is the name of a record
- 3. Each column is the data field corresponding to the record name
- 4. Many rows and columns form a table
- 5. Several tables form a database
RDBMS Terminology
Before we start learning the MySQL database, let's first understand some RDBMS terminology:
- Database: A database is a collection of related tables.
- Table: A table is a matrix of data. A table in a database looks like a simple spreadsheet.
- Column: A column (data element) contains data of the same type, for example postal code data.
- **Row:** A row (tuple, or record) is a set of related data, for example a record of a user subscription.
- Redundancy: Storing data twice. Redundancy reduces performance but improves data security.
- Primary key: A primary key is unique. A data table can contain only one primary key. You can use the primary key to query data.
- **Foreign key:** A foreign key is used to relate two tables.
- Composite key: A composite key (combination key) uses multiple columns as an index key, generally used for composite indexes.
- **Index:** Using an index provides fast access to specific information in a database table. An index is a structure that sorts the values of one or more columns in a database table, similar to the table of contents of a book.
- Referential integrity: Referential integrity requires that a relation must not reference non-existent entities. Together with entity integrity, it is an integrity constraint that the relational model must satisfy, aiming to ensure data consistency.
MySQL is a relational database (Relational Database Management System). This so-called "relational" can be understood as the concept of "tables"; a relational database consists of one or several tables, as shown in the figure:

- Header: the name of each column;
- Column (col): a collection of data with the same data type;
- Row: each row is used to describe the specific information of a record;
- Value: the specific information of a row; each value must have the same data type as the column;
- Key: the value of a key is unique within the current column.
MySQL Database
MySQL is a relational database management system developed by the Swedish company MySQL AB and currently owned by Oracle. MySQL is a relational database management system; a relational database stores data in different tables rather than putting all data in one large warehouse, which increases speed and improves flexibility.
- MySQL is open source and is currently a product of Oracle.
- MySQL supports large databases. It can handle large databases with tens of millions of records.
- MySQL uses the standard SQL data language form.
- MySQL can run on multiple systems and supports many languages. These programming languages include C, C++, Python, Java, Perl, PHP, Eiffel, Ruby, Tcl, and others.
- MySQL has very good support for PHP, which is very suitable for web application development.
- MySQL supports large databases, data warehouses with 50 million records; on 32-bit systems the maximum table file size supported is 4GB, and on 64-bit systems the maximum table file size supported is 8TB.
- MySQL is customizable and adopts the GPL license; you can modify the source code to develop your own MySQL system.
What you should know before starting this tutorial?
Before starting this tutorial, you should have a basic knowledge of PHP and HTML and be able to apply them simply.
Many examples in this tutorial are related to the PHP language, and our examples are basically demonstrated using PHP.
If you do not yet know PHP, you can use the PHP Tutorialon this site to learn the language.