I've always wonder how large sites handle massive databases?

Is it efficient for say facebook to have 1 server for friends database, another server with just the wall posts database etc etc? You can use different connections to get the data, and use another server for comparing data on temp tables?

Or how does PHP coding change if you have the MySQL database fragmented across multiple servers?

If someone could clear up my understanding it would be appreciated .