There are many databases that PHP supports but the MySQL database is the most popular among them. After going through the PHP Basics, Form Handling, Advanced topics, and then OOP, we are ready to start new Database series of PHP tutorials.
In this Database series, we will learn to connect, communicate and perform database operations. Hopefully, you will enjoy these things.
What is MySQL Database?
SQL stands for the structured query language. We use SQL queries to perform the Create, Read, Update and Delete (CRUD) operations with our data. MySQL is a database product used to store and organize user data. It is oftenly known as RDMS (relational database management system) as it maintains the relationships across the database tables.
Listing down the features and properties of MySQL
- Database system widely used on the web.
- It executes on server.
- Compatible with both small and large scale applications.
- As compared to other databases, it is fast, reliable and easy to use with PHP.
- MySQL use standard SQL language.
- It is compatible on a number of platforms. Works with consitency.
- It is free to download and use.
- Oracel corporation are its developers and ditrubuters too.
- Name after its co-founder Monty Widenius Daughter (My).
How data is stored in MySQL Database?
- MySQL store the data in tables.
- Each table comprises of rows and columns.
- MySQL support the realationship between two and more tables.
Why we need database ?
- Till now, we have been storing our data in arrays, variables, constants, objects etc. But the data stored in these is not persistent. It removes after the termination of the program.
- To store the data permanently, we need to store it in permanent storage. It can be either files or some database like MySQL.
Storing Data in Files vs MySQL Database
|File Storage||Database Storage|
|File storage stores the data in the form of files. These files are stored on the Hard disk of the computer.||Database stores data in form of tables. These tables are stored on the Hard disk of the computer.|
|Reading and writing data in files is slower.||Reading and writing data in the database is faster because it is arranged in tables and query languages are used to perform the searching.|
|Data is not stored in an organized manner, due to which searching the data takes a long time, which makes it slower.||Searching data in tables is much faster than files. This is because of multiple reasons. Indexing, relationships, primary and foreign keys are the major key factors behind this.|
We will be working on some real-world database examples like considering a company that sells the products. Its database should look like having the following tables.
A query is a request to the database server. It performs one of the following operations in the database.
- Create – Create query add new item in the database.
- Read – Read query fetch the records from database tables. It can be a filtered data based on some conditions. We will cover it later.
- Update – Performs the modification in the already existing records in the database.
- Delete – Perfoms removal/deletion of record from the database.
Interesting Facts about MySQL
- Huge volumetric data companies like Facebook, Wikipedia and Twitter use MySQL as there primary databases.
- Scaling up or down according to the number of requests is one of the useful features of MySQL.
- You can download PHP server with MySQL database from http://www.mysql.com
- To read more about the companies using MySQL visit http://www.mysql.com/customers/