Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6191819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:50:01+00:00 2026-05-24T02:50:01+00:00

I’m new to MongoDB and as an exercise I’m building an application that extracts

  • 0

I’m new to MongoDB and as an exercise I’m building an application that extracts links from tweets. The idea is to get the most tweeted articles for a subject. I having a hard time to design the schema for this application.

  • The application harvest tweets and saves them
  • The tweets are parsed for links
  • The links are saved with additional information (title, excerpt, etc.)
  • A tweet can contain more then one link
  • A link can have many tweets

How do I:

  • Save these collections, Embedded Document?
  • Get the top ten links sorted by number of tweets they have?
  • Get the most tweeted link for a specific date?
  • Get the tweets for a link?
  • Get the ten latests tweets?

I would love to get some input on this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T02:50:01+00:00Added an answer on May 24, 2026 at 2:50 am

    two general tips:
    1.)don’t be afraid to duplicate. It is often a good idea to store the same data differently formatted in different collections.

    2.) if you want to sort and sum up stuff, it helps to keep count fields everywhere. mongodb’s atomic update method together with upsert commands make it easy to count up and to add fields to existing documents.

    The following is most certainly flawed because it’s typed from the top of my head. But better bad examples than no examples I thought 😉

    colletion tweets:
    
    {
      tweetid: 123,
      timeTweeted: 123123234,  //exact time in milliseconds
      dayInMillis: 123412343,  //the day of the tweet kl 00:00:00
      text: 'a tweet with a http://lin.k and an http://u.rl',
      links: [
         'http://lin.k',
         'http://u.rl' 
      ],
      linkCount: 2
    }
    
    collection links: 
    
    {
       url: 'http://lin.k'
       totalCount: 17,
       daycounts: {
          1232345543354: 5, //key: the day of the tweet kl 00:00:00
          1234123423442: 2,
          1234354534535: 10
       }
    }
    

    add new tweet:

    db.x.tweets.insert({...}) //simply insert new document with all fields
    
    //for each found link:
    var upsert = true;
    var toFind =  { url: '...'};
    var updateObj = {'$inc': {'totalCount': 1, 'daycounts.12342342': 1 } }; //12342342 is the day of the tweet
    db.x.links.update(toFind, updateObj, upsert);
    

    Get the top ten links sorted by number of tweets they have?

    db.x.links.find().sort({'totalCount:-1'}).limit(10);
    

    Get the most tweeted link for a specific date?

    db.x.links.find({'$gt':{'daycount.123413453':0}}).sort({'daycount.123413453':-1}).limit(1); //123413453 is the day you're after
    

    Get the tweets for a link?

    db.x.tweets.find({'links': 'http://lin.k'});
    

    Get the ten latests tweets?

    db.x.tweets.find().sort({'timeTweeted': -1}, -1).limit(10);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I want use html5's new tag to play a wav file (currently only supported
I am doing a simple coin flipping experiment for class that involves flipping a
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.