how to integrate facebook login with your website?
The idea behind Facebook login is simple: The user goes to the Facebook page, logs in there, Facebook worries about the details and eventually just gives you (your server) a thumbs up and an id, meaning "we have positively confirmed the identity of this user, it's user 174264384". Your server is then free to do whatever it likes with this information. If you want to track a user across several visits then yes, you'll probably want to store that number in a database together with any additional information. The next time Facebook tells you user 174264384 has logged in, you can get any associated information back out of your database.
Hope that helps as a 30,000 feet overview. The details of how Facebook can securely authenticate a user and hand this information back to your server are best handled by the PHP SDK. Read the documentation if you want to explore the details.
OpenID basically does the same thing, only the technical details differ and it's not specific to Facebook. Oauth is another very similar technology.
There is an official Facebook tutorial on how to do this with JS:
Official Facebook Tutorial
This type of technology (called OpenConnect, if I'm not mistaken, and they are switching to OAuth) is somewhat the same with OpenID.
Google, indeed, uses openID, and I am not really sure of how they work.
For FacebookConnect, you register your app with facebook ( https://developers.facebook.com/apps ) and you will find details about auth https://developers.facebook.com/docs/authentication/ here.
The idea is that you are going to get a authorization code that you send back to facebook and get an access_token which means your user is authed with your website. You can store this in a $_SESSION var I think... There is no need to store anything to DB, but in your particular setup you can use the userID as the unique user identifier.