Saving users in DB

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 details of the users.

When implementing the Facebook login, I had a question.

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

What do you recommend / how do you usually do?

Thank you in advance.

    
asked by anonymous 23.07.2016 / 09:41

1 answer

1

I'll give you a hint of recent experience. I had to do the same thing you're doing now with LinkedIn in a legacy system.

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

In this way you can store all user information by external logins and keep the internal login data you already have, this also opens the possibility that the user can log in with more than one account, since you will have to have one field with the name "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 connect more than one external account to their system without losing the original login and it would be much easier for you to fetch the data, since ids are always unique.

    
23.07.2016 / 17:32