Mysql 简明教程

MySQL - Introduction

What is a Database?

数据库用于存储数据集合(可以是结构化的或非结构化的)。每个数据库都具有一个或多个不同的 API,用于创建、访问、管理、搜索和复制其保存的数据。

A database is used to store a collection of data (which can either be structured or unstructured). Each database has one or more distinct APIs for creating, accessing, managing, searching and replicating the data it holds.

其他类型的数据存储也可用于管理数据,例如文件系统上的文件或内存中的大型哈希表,但对于此类系统,数据提取和写入不会那么快速和容易。

Other kinds of data storages can also be used to manage data, such as files on the file system or large hash tables in memory, but data fetching and writing would not be so fast and easy with those type of systems.

如今,我们使用关系数据库管理系统(RDBMS)来存储和管理海量数据。在此类数据库中,数据以结构化的方式存储,借助于不同的表。在这些表之间使用主键或称为 Foreign Keys 的其他键建立关系。

Nowadays, we use relational database management systems (RDBMS) to store and manage huge volume of data. In such a database, the data is stored in a structured way with the help of different tables. Relations are established among these tables using primary keys or other keys known as Foreign Keys.

Relational DataBase Management System (RDBMS) 是一个软件 −

A Relational DataBase Management System (RDBMS) is a software that −

  1. Enables you to implement a database with tables, columns and indexes.

  2. Guarantees the Referential Integrity between rows of various tables.

  3. Updates the indexes automatically.

  4. Interprets an SQL query and combines information from various tables.

RDBMS Terminology

在我们继续解释 MySQL 数据库系统之前,让我们复习几个与数据库相关的定义。

Before we proceed to explain the MySQL database system, let us revise a few definitions related to the database.

  1. Database − A database is a collection of tables, with related data.

  2. Table − A table is a matrix with data. A table in a database looks like a simple spreadsheet.

  3. Column − One column (data element) contains data of one and the same kind, for example the column postcode.

  4. Row − A row (= tuple, entry or record) is a group of related data, for example the data of one subscription.

  5. Redundancy − Storing data twice, redundantly to make the system faster.

  6. Primary Key − A primary key is unique. A key value can not occur twice in one table. With a key, you can only find one row.

  7. Foreign Key − A foreign key is the linking pin between two tables.

  8. Compound Key − A compound key (composite key) is a key that consists of multiple columns, because one column is not sufficiently unique.

  9. Index − An index in a database resembles an index at the back of a book.

  10. Referential Integrity − Referential Integrity makes sure that a foreign key value always points to an existing row.

MySQL Database

MySQL 是一款快速、易于使用的 RDBMS,用于许多小公司和大公司。它是由瑞典公司 MySQL AB 开发、销售和提供支持的。MySQL 变得如此受欢迎是有很多原因的 −

MySQL is a fast, easy-to-use RDBMS being used for many small and big businesses. It is developed, marketed and supported by MySQL AB, which is a Swedish company. MySQL is becoming so popular because of many good reasons −

  1. MySQL is released under an open-source license. So you have nothing to pay to use it.

  2. MySQL is a very powerful program in its own right. It handles a large subset of the functionality of the most expensive and powerful database packages.

  3. MySQL uses a standard form of the well-known SQL data language.

  4. MySQL works on many operating systems and with many languages including PHP, PERL, C, C++, JAVA, etc.

  5. MySQL works very quickly and works well even with large data sets.

  6. MySQL is very friendly to PHP, the most appreciated language for web development.

  7. MySQL supports large databases, up to 50 million rows or more in a table. The default file size limit for a table is 4GB, but you can increase this (if your operating system can handle it) to a theoretical limit of 8 million terabytes (TB).

  8. MySQL is customizable. The open-source GPL license allows programmers to modify the MySQL software to fit their own specific environments.

History of MySQL

  1. Development of MySQL by Michael Widenius & David Axmark beginning in 1994.

  2. First internal release on 23rd May 1995.

  3. Windows Version was released on the 8th January 1998 for Windows 95 and NT.

  4. Version 3.23: beta from June 2000, production release January 2001.

  5. Version 4.0: beta from August 2002, production release March 2003 (unions).

  6. Version 4.1: beta from June 2004, production release October 2004.

  7. Version 5.0: beta from March 2005, production release October 2005.

  8. Sun Microsystems acquired MySQL AB on the 26th February 2008.

  9. Version 5.1: production release 27th November 2008.

  10. Oracle acquired Sun Microsystems on 27th January 2010.

  11. Version 5.5: general availability on 3rd December 2010

  12. Version 5.6: general availability on 5th February 2013

  13. Version 5.7: general availability on 21st October 2015

  14. Version 8.0: general availability on 19th April 2018

Before You Begin

在开始本教程之前,您应该对我们 PHP 和 HTML 教程中涵盖的信息有基本的了解。

Before you begin this tutorial, you should have a basic knowledge of the information covered in our PHP and HTML tutorials.

本教程重点介绍在 PHP 环境中使用 MySQL。本教程给出的许多示例对 PHP 程序员来说很有用。

This tutorial focuses heavily on using MySQL in a PHP environment. Many examples given in this tutorial will be useful for PHP Programmers.

我们建议您查看我们的 PHP Tutorial 供您参考。

We recommend you check our PHP Tutorial for your reference.