PHP MySQL Introduction
MySQL is the most popular database system used with the PHP language.
What is MySQL
MySQL is one of the most popular relational database system being used on the Web today. It is freely available and easy to install, however if you have installed Wampserver it already there on your machine. MySQL database server offers several advantages:
- MySQL is easy to use, yet extremely powerful, fast, secure, and scalable.
- MySQL runs on a wide range of operating systems, including UNIX or Linux, Microsoft Windows, Apple Mac OS X, and others.
- MySQL supports standard SQL (Structured Query Language).
- MySQL is ideal database solution for both small and large applications.
- MySQL is developed, and distributed by Oracle Corporation.
- MySQL includes data security layers that protect sensitive data from intruders.
MySQL database stores data into tables like other relational database. A table is a collection of related data, and it is divided into rows and columns.
Each row in a table represents a data record that are inherently connected to each other such as information related to a particular person, whereas each column represents a specific field such as id, first_name, last_name, email, etc. The structure of a simple MySQL table that contains person's general information may look something like this:
+----+------------+-----------+----------------------+ | id | first_name | last_name | email | +----+------------+-----------+----------------------+ | 1 | Peter | Parker | [email protected] | | 2 | John | Rambo | [email protected] | | 3 | Clark | Kent | [email protected] | | 4 | John | Carter | [email protected] | | 5 | Harry | Potter | [email protected] | +----+------------+-----------+----------------------+
Tip: Websites like Facebook, Twitter, Wikipedia uses MySQL for their storage need. So you can easily understand what MySQL is capable of.
Talking to MySQL Databases with SQL
SQL, the Structured Query Language, is a simple, standardized language for communicating with relational databases like MySQL. With SQL you can perform any database-related task, such as creating databases and tables, saving data in database tables, query a database for specific records, deleting and updating data in databases.
Look at the following standard SQL query that returns the email address of a person whose first name is equal to 'Peter' in the persons table:
If you execute the SQL query above it will return the following record:
To learn more about SQL, please checkout the SQL tutorial section.