Search code examples
phpdatabasefacebook-loginwebshop

Database design for linking multiple account types


I'm building a website where users can pay for a certain service provided by the owner. It's not an online shop, though the payment process is pretty similar.

The problem I'm facing lies in the different 'login' options during this payment process. One can use a Facebook-account to log in, register for an account/login using his account OR choose to fill in personal info without registering.

I was thinking about a 'consumers' table (one time users without an account), a 'users' table for registered users, a 'facebook_accounts' table with the Facebook info, and a 'user_has_facebook_account' table for linking Facebook accounts to registered users based on a shared email address.

However, what if a user logs in using Facebook without having a registered account with a password... It's really giving me a headache.

Any suggestions how I would go about designing a database to support this?


Solution

  • I would create only one table with customers. There you can have a field with the Facebook user ID. If someone login with Facebook, you can create a new record for him (you have email address etc. from Facebook). Therefore, you can set an empty local password or require the user to set a password for your page.