MongoDB

The last database type that we will look at is known as a NoSQL type of database. NoSQL databases are on the rise in popularity because they are also quite lightweight in terms of system resources, but more importantly, they work outside the typical SQL command structure. NoSQL DBs are also becoming more popular with mobile devices like tablets and smartphones for the above two reasons.

One of the frontrunners in the NoSQL database world is known as MongoDB, and it will be the focus of this last section of the database chapter. We will only be touching the surface of the MongoDB product here, just to give you a taste of what is possible with its use. For more detailed coverage of this topic, please refer to MongoDB and PHP by Steve Francia (O’Reilly).

The first thing to get your head around with MongoDB is that it is not a traditional database. It has its own setup and its own terminology. Getting used to how to work with it will take some time for the traditional SQL database user. Table 8-3 is an attempt at drawing some parallels with “standard” SQL terminology.

Table 8-3. Typical MongoDB/SQL equivalents

Traditional SQL terms

MongoDB terms

Database

Database

Tables

Collections

Rows

Documents. No correlation, not like database “rows.” Rather, think of arrays.

It is difficult to draw the equivalent of a database row within the MongoDB paradigm. It is said one of the best ways to think of the data within a collection is to consider it like that of a multidimensional array, and we will ...

Get Programming PHP, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.