Create an address book with PHP

This article first appeared in issue 228 of .net magazine – the world's best-selling magazine for web designers and developers.

MongoDB is a document database designed for performance and scale while remaining easy for developers to use. The term document database is often misunderstood – it’s not referring to PDF and DOC files, but a document database in this case means storing arrays. MongoDB is often grouped with other non-relational databases, called NoSQ.

MongoDB provides two features that can be considered groundbreaking. First, it works with native language types, so the database works for you rather than you having to conform to it. It feels so natural to simply save arrays or objects that you’ll quickly forget you are using a database. Second, the schema is totally flexible meaning that each record can contain different fields. When working on an address book application, it struck us that this flexible structure would be fabulous for dealing with all the various kinds of contacts!

I have address book entries for people who have three email addresses, but no postal address. Then there’s Auntie Flo, who has two postal addresses because she migrates with the sun – but she doesn’t have a mobile phone. This article goes through how to design the schema to use with MongoDB, and how we built a PHP application on top of it.

Thank you for reading 5 articles this month* Join now for unlimited access

Enjoy your first month for just £1 / $1 / €1

*Read 5 free articles per month without a subscription

Join now for unlimited access

Try first month for just £1 / $1 / €1

TOPICS

The Creative Bloq team is made up of a group of design fans, and has changed and evolved since Creative Bloq began back in 2012. The current website team consists of eight full-time members of staff: Editor Georgia Coggan, Deputy Editor Rosie Hilder, Ecommerce Editor Beren Neale, Senior News Editor Daniel Piper, Editor, Digital Art and 3D Ian Dean, Tech Reviews Editor Erlingur Einarsson and Ecommerce Writer Beth Nicholls and Staff Writer Natalie Fear, as well as a roster of freelancers from around the world. The 3D World and ImagineFX magazine teams also pitch in, ensuring that content from 3D World and ImagineFX is represented on Creative Bloq.