1

I'm developing a Web app that revolves around the Twitter API. I'm a newbie and this is my first ever attempt at development so be gentle (please).

The problem I'm facing is: I have a table that contains the twitter user info: UserID(Unique) Name etc.. And another with specific tweets: TweetID(Unique) Text etc..

I want to be able specify if a particular UserID has Retweeted the tweet(using TweetId) already.

I don't care if he has retweeted outside my App, I just want to know if he did using my web app so I don't display it to him twice.

reto
  • 9,995
  • 5
  • 53
  • 52
Micael Dias
  • 331
  • 2
  • 12
  • Your question is too broad and does not provide information on what you have already done. Please post your code and the error message you get, if your current problem is about the database design you should post in dba exchange instead – Purefan Mar 05 '15 at 10:17
  • 1
    Yes It's about creating the database. I didn't know there was another forum for that. I asked there, thank you. – Micael Dias Mar 05 '15 at 10:26

1 Answers1

1

It's kind of conventional to name your columns in small letters(snake_case_ name_of_column).

Are you asking for schema or query?

If schema,

  1. Firstly, create another (one-to-many relationship) table named user_tweets that have columns (id | tweet_id | user_id). The columns are foreign keys to the tweet table and user_id table

  2. For each tweet, you insert the tweet_id and user_id irrespective if it was a re-tweet or not,

For each tweet or re-tweet, you insert a new tweet record in the user_tweets table and when retrieving record to display a users tweets, you select only distinct records from the user_tweets table where the user id is for the user you are looking for, This returns the distinct tweets.

Hope this helps.

Community
  • 1
  • 1
JohnTheBeloved
  • 2,323
  • 3
  • 19
  • 24
  • Yes, that's exactly what I was looking for! I will give it a go when I get home, Thanks a lot. I would vote up but I don't have enought reputation :( – Micael Dias Mar 05 '15 at 10:44