Relational database management systems
Learn what the most common relational databases in PHP are.
We'll cover the following
We can work with relational databases via relational database management systems (RDBMS), which are applications that provide all the functionality to store and manage databases. Here are the three most common ones.
MySQL
MySQL is PHP’s most common database management system. Their website claims it’s “the world’s most popular open-source database.” For our purposes, MySQL has wide support, many instructional books and guides, and a vast community. If something’s written in PHP and works with a database, it was probably written with MySQL in mind.
PostgreSQL
PostgreSQL is less popular than MySQL, but the difference is slowly shrinking. Their website claims it’s “the world’s most advanced open-source relational database.” It has less support than most PHP libraries, but provides more features, functions, and supported data types.
SQLite
SQLite is not as powerful as the previous two, but it does have one exciting feature—it doesn’t need a running server to work with a database. Instead, SQLite works as a C library, so we use it just like functions to work with a single database file. We can bundle SQLite into applications shipped to customers since it doesn’t have any special infrastructure requirements.
Their website claims it’s “the world’s most used database engine.” The difference between MySQL and SQLite is that MySQL usually runs server-side and SQLite works client-side.
Using them in PHP
There are different database-specific extensions for PHP, but it’s better to use PDO, an extension that provides a consistent interface for various relational databases.
Even though PDO already abstracts over multiple database engines, it’s worth using an abstraction layer library because they provide friendlier and faster-evolving interfaces. The most common such library is database abstraction layer (DBAL).
Conclusion
Relational databases are not a single tool but rather a theoretical construct. There are multiple relational database management systems implementing them, and each is best suited for a particular use case.
We should avoid working with RDBMS directly and use an abstraction layer instead.
Get hands-on with 1200+ tech skills courses.