0

I have two types of users on the database: -Web registered users -Twitter users

I have to store data of both: - Web registered users: id, nick, mail, verified, password - Twitter users: id, nick

Currently i have just 2 tables: - webUsers: id, nick, mail, verified, password - twitterUsers: id, nick

But it carry some problems for example with the comments table. Both users can make comments so i would need two foreigns key and that's not possible.

I also thought about this possibility: - users: id, nick - users_twitter: id, - users_web: id, nick, mail, verified, password.

It would represent the main table users with two childrens: users_twitter and users_web. But... the table users_twitter has only one field: id isn't that weird?

What would you recommend me? OH, by the way. Twitter users id is the one i get from twitter API, so it might be possible that ID could be same of my of the web users ID.

Thanks.

Alvaro
  • 40,778
  • 30
  • 164
  • 336

1 Answers1

0

So, you've a hierarchy there. You have some common fields that could be part of a Users table and some others that should be part of each of the childrens: UsersTwitter and UsersWeb. You can take a look at this post to see how to handle hierarchies.

Community
  • 1
  • 1
Mosty Mostacho
  • 42,742
  • 16
  • 96
  • 123
  • I am just wondering if creating a whole table just for a duplicate field "id" would be right or not. But thinking about it. Maybe it would be a better idea to create 2 id's for twitter users. The autoincrement ID i have on my users table and then the twitter Id. So now my twitter_users table would have: id, twitterId Would it be correct? THanks!! – Alvaro Mar 25 '12 at 16:16
  • This is not named "hierarchy". It's the supertype/subtype pattern. Hierarchies are something different. – ypercubeᵀᴹ Mar 25 '12 at 16:20