Saving users in BD

Asked

Viewed 46 times

1

Good morning.

I have a login and registration system via PHP, with Mysql database. In this database I have a table with login, password, name and other user details.

When implementing Facebook login, I had a question.

To store the FBID, Facebook name and surname, FB email and etc, it would be more practical/recommended to save in the same table of users (having to merge some information) or create a new table to store Fb data and then link only the PK of that table in the main user table?

What you recommend / how you usually do?

Thanks in advance.

1 answer

1


I’ll give you a tip of recent experience. I had to do the same thing you’re doing now with Linkedin on a legacy system.

I recommend the second option, that is, create a new table where the primary key is the type of external integration you are performing (a column with the name TYPE_EXTERNAL, for example, and in this field you put values like "FB", "LKDN", "TT" and all other services you want to link to login) and another column with the existing user id in your original system table as a foreign key.

This way you can store all user information by external logins and keep the login data you already had, this also opens the possibility for the user to log in with more than one account, because you will have to have a more or less field with the name of "EXTERNAL_ID", this would be the ID field that FB or any other service would return as the user’s unique ID, so each user could call more than one external account on their system without losing the original login and it would be much easier for you to fetch the data, since ids are always unique.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.