I’m designing a schema table that will manage the auth tokens for integrations // app with social networks.
At the moment only for Twitter and Facebook.
I’m thinking in this mode
id social tw_token tw_token_auth tw_secret tw_secret_key fb_token fb_secret
1 twitter aaa bbbb cccc dddd NULL NULL
2 facebook NULL NULL NULL NULL AAA1 bbb3
I don’t like that many NULL, but for a so-simple-schema I would not realize a different table for social networks.
How to perform this better than I’m doing now?
1
If I understand you correctly, you plan to have a table with a record for each social media account, and one column for each piece of authentication data for each site.
That last part is horribly bad. A schema that has to be changed (by adding columns) whenever a new record is inserted is a really, really bad idea. Either username/password/token or whatever you are using fulfill comparable purposes on different sites. Then they should be in the same column, not in a special-purpose site-specific column. Or they are fundamentally different. Then they need different columns, but it should be the same column for every site that also uses this information. Sites that don’t use this particular mechanism can have NULL
there. But altogether, there is no reason why you should have more columns than the number of authentication items that the most complex supported site uses.
4