1

I am trying to create a proper schema to place scraped data into, using a MongoDB database.

Currently it looks like

Team {
    id : id,
    name : String,
    teamLink : String,
    username : String,
    userLink : String,
    league : Number,
    Rank : {
        global : Number,
        division : Number
    },
    Points : {
        global : Number,
        division : Number
    }
    Stats : [{
        desc : String,
        value : String,
        globalRank : Number,
        globalPts : Number,
        divRank : Number,
        divPts : Number
    }]
}

League {
    id : Number,
    name : String,
    link : String,
    division : Number,
    acrive : Boolean
    rankings : [{
        week : Number,
        ranks : [{
            team : String,
            position : Number,
            points : Number
        }]
    }]
}

The problem is that a lot of this makes it hard to quickly rank over something as simple as a single stat (e.g. HR). So I am trying to better understand on how to model the data to say, quickly sort over HRs or easily obtain the rankings. I come from a relational db background so I am having a hard time adjusting without joins.

Thank you

2
  • 3
    I hate to burst your bubble but this is structured relational data, and would likely work a LOT better in a SQL database.
    – JNK
    Apr 3, 2014 at 17:49
  • Fully aware it would work a hell of a lot better under a relational database; however, this was more of a learning exercise than anything else. What would be the optimal way to arrange it?
    – BenM
    Apr 3, 2014 at 18:03

1 Answer 1

1
Team {
    id : id,
    name : String,
    teamLink : String,
    username : String,
    userLink : String,
    league : Number,
    Stats : [{
        desc : String,
        value : String,
        globalRank : Number,
        globalPts : Number,
        divRank : Number,
        divPts : Number,
        year:Number
    }]
}

League {
    id : Number,
    name : String,
    link : String,
    division : Number,
    acrive : Boolean
}

rankings : {
            week : Number,
            league_id: Number,
            year: Number,
            ranks : [{
                team_id : Number,
                position : Number,
                points : Number
            }]
        }

match {
       id : Number,
       league : Number
       team_visit : Number,
       team_ext : Number,
       ining : Number,
       time_start : Datetime,
       time_game : Number,
       team_visit_score : Number,
       team_ext_score : Number    
}

EDIT: explain schema.

  • First is necessary separate all stats for team in a interval time, because changes in time for season, years, stats, etc...

  • Add the match documents, for each match a document. Separate all for documents, League, Teams, Ranks, is better for search and relation with others team in match, rank...

  • And the solution is MySQL I'm not so sure about that, because if you have a lots data in match, league, teams, ranks... Is Better documents with all stats of any team, or all rank in any interval time because in MySQL you need JOINS for that.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.