简体   繁体   中英

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?

You should probably be adding people that login with Facebook to the Users table and creating them a default password, as well as storing the OAuth information / keys.

Your "User" objects should be singular and just have a different method for how they became "Users" to simplify things

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM