I'm building a site ("The Site") and I'm considering how to design the DB schema for it.
I have a few scenarios that will affect the outcome:
- The user can choose to register a native account on the site, which will make him use that account for login in to his account on the site in the future.
- The user can choose to login via another site ("external site") (such as facebook connect, google, foursquare, etc..), which will make him use that for login in to his account on the site in the future.
- Doesn't really matter which login method he chose (native account or external site account), the user will be able to authenticate his account on the site with external sites (such as facebook, twitter, instagram, etc...) for using the data he has on the external site (such as his tweets from twitter, his photos from flickr, etc..), in the site.
How should I design the schema of the DB ?
For the first two scenarios, I thought of having a table called
Users that has an
id, and a
type fields. The type reference a different table, such as
GoogleUsers, each has a
user_id field - which has a foreign relation to the
Users.id field - and other fields such as the
- I'm not sure how smart it is to use this approach.
- I don't know how to implement the third scenario in such an approach.