Those "databases and other systems" make up a significant portion of their code base, and in many cases Facebook either contributes to their development or created them internally. To claim that Facebook is written entirely in PHP is false. Examples:
- Cassandra (Java) was created by Facebook http://en.wikipedia.org/wiki/Apache_Cassandra
- Giraph (Java) has significant contributions from Facebook and I believe was founded there http://giraph.apache.org/
- FP (Erlang IIRC) at Facebook http://cufp.org/videos/functional-programming-facebook
- Facebook's page listing some of the open source projects they contribute to https://developers.facebook.com/opensource/