I have an application where a user is able to sign up by providing email, username and password
.
This would be stored in mongoDB collection Users_Table
. Now also the app allows users to sign with their social media account
, if the user has one such facebook, google account and twitter
.
Question is how do i go about designing the database?
My initial idea is to have 2 separate collections. The first collection has user information if he or she registers with the app.
User_Table (
Id,
firstname,
lastname,
email,
phone_number)
The second collection stores the social media account such as facebook, google, or twitter if the user has one.
I will retrieve users firstname, lastname, email and phone_number from their social media account and store it in the collection. This will be stored in the second collection.
Now if a user who has signed in with facebook decides to register with the app, how do i merge both accounts i.e. if its the same user how do i link them?