MySQL Tutorial
MySQL is the most popular relational database management system, and it is one of the best RDBMS (Relational Database Management System) applications for web applications.
In this tutorial, you will quickly grasp the basics of MySQL and easily use MySQL databases.
What is a Database?
A database (Database) is a warehouse that organizes, stores, and manages data according to data structures.
Each 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, nowadays we use relational database management systems (RDBMS) to store and manage large amounts of data. A relational database is a database based on the relational model, using mathematical concepts and methods such as set algebra to process data in the database.
The characteristics of RDBMS (Relational Database Management System) are:
- Data appears in tabular form
- Each row is a variety of record names
- Each column is the data field corresponding to the record name
- Many rows and columns form a table
- Several tables form a database
RDBMS Terminology
Before we start learning MySQL databases, let's first understand some RDBMS terminology:
Database: A database is a collection of related tables.
Data 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, such as postal code data.
Row: A row (tuple, or record) is a set of related data, such as data for a user subscription.
Redundancy: Storing double data, redundancy reduces performance but improves data security.
Primary Key: The primary key is unique. A data table can only contain one primary key. You can use the primary key to query data.
Foreign Key: A foreign key is used to associate two tables.
Composite Key: A composite key (combined key) uses multiple columns as an index key, typically for composite indexing.
Index: An index allows quick access to specific information in the 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 in a book.
Referential Integrity: Referential integrity requires that relationships do not reference non-existent entities. It, along with entity integrity, is a condition that relational models must satisfy to ensure data consistency.
MySQL is a relational database (Relational Database Management System), where the term "relational" can be understood as the concept of "table." A relational database consists of one or more tables, as shown in the figure:
Header: The name of each column;
Column (col): A collection of data with the same data type;
Row (row): Each row describes specific information about a record;
Value: Specific information of a row, each value must be of the same data type as the column;
Key (key): The key value is unique within the current column.
MySQL Database
MySQL is a relational database management system developed by Swedish company MySQL AB, now owned by Oracle Corporation. MySQL is an associative database management system, which stores data in different tables rather than putting all data in a large warehouse, which increases speed and flexibility.
MySQL is open-source and currently owned by Oracle.
MySQL supports large databases. It can handle large databases with tens of millions of records.
MySQL uses standard SQL data language forms.
MySQL can run on multiple systems and supports multiple languages. These programming languages include C, C++, Python, Java, Perl, PHP, Eiffel, Ruby, and Tcl, among others.
MySQL has good support for PHP, which is very suitable for web application development.
MySQL supports large databases, supporting data warehouses with up to 50 million records, with table files up to 4GB on 32-bit systems and up to 8TB on 64-bit systems.
MySQL is customizable, using the GPL protocol, allowing you to modify the source code to develop your own MySQL system.
What Should You Know Before Starting This Tutorial?
Before starting this tutorial, you should have a basic understanding of PHP and HTML and be able to use them simply.
Many examples in this tutorial are related to the PHP language, and our examples are mostly demonstrated using PHP.
If you are not familiar with PHP, you can learn about the language through our PHP tutorial.