How does website for mobile pull database from the normal website

Hi,
I am seeking suggestion on the method facebook pull database from its normal website to be used in the web site for mobile?

Say, when your friend gives a comment on your facebook.com account, it also appeared on your m.facebook.com too.

Thanks in advance

They take the data for both sites from the same database?

I have no idea. That’s why I am asking.

I want to make a for mobile version of my website too.

m.facebook.com” is NOT a mobile app. It is simply another URI (web resource) that contains stylesheet(s) for mobile.
They don’t “pull from the same database”. You are viewing the same website - styled differently for the mobile device.