Giter Site home page Giter Site logo

Comments (4)

dget avatar dget commented on July 17, 2024

Hey @F4nt, I'm trying to get a sense of what the different things in the DB schema are supposed to be.

Why would different models FK to GamePlayer instead of separately to Game and Player?

My gut says you'll most often want to query against one or the other, and not as often for the game-instance of a player (with the biggest reason I see for that being to fetch the statline for a player in a game). Neither access pattern is impossible either way, but it seems like it'll be cleaner to do Game and Player.

from mls-api.

rogersmark avatar rogersmark commented on July 17, 2024

Hey @dget,

The main thing that ended up driving that is that players often play out of position and I wanted to capture that. For instance, Logan Pause is a central midfielder but played at RB for the Fire last week against Montreal. It wouldn't make sense to change his position on the Player object, because that should be (mostly) constant.

I wanted the flexibility to be able to filter down and see games where Pause played RB, and be able to see what affect that may or may not have had on outcomes. Having Player and GamePlayer lets us use Player as a constant of sorts, perhaps for displaying rosters, while GamePlayer can be used for game day stats line as you mentioned.

from mls-api.

dget avatar dget commented on July 17, 2024

That seems fair. For something like substitution, do you think it should have an FK to both Game and GamePlayer, or just GamePlayer? I'm thinking just GamePlayer, but noticed Goal has both, and want to make sure whatever I end up adding is consistent.

from mls-api.

rogersmark avatar rogersmark commented on July 17, 2024

Good question. The reason Goal has both is to simplify the query to get the totals for displaying the score. Admittedly, that isn't really necessary, and I could aggregate the totals through the GamePlayer model, but it felt cumbersome and messy. Thus the FKs to Game and GamePlayer. I could really go either way on it though, as it does border on extraneous.

I'd think with Subs we could just FK to GamePlayer. I can't think of any great benefit to FK to Game as well, and it sounds like your thoughts on similar there. That said, if you can think of a benefit of FK to Game, I'm open to it.

By the way, if it's easier, feel free to email me anytime at: f4nt AT f4ntasmic DOT com.

from mls-api.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.