Data Modeling for Soccer Match Statistics

Hello everyone. I have the following situation. I am building a data and statistics application from 1933 to date for a soccer team in Chile called Audax Italiano.

Within the components that I have, there are several tables that are already developed, among those I have:

Matches: where Audax faces a rival and a score, result, goals, etc. is associated.
Players: table of players, of which, the goals are added and particular information of the player is incorporated (photograph, date of birth, position, etc).

My question is in which “Matches” I always select which player scored the goal in Audax Italiano, the problem is that there are cases in which the same player in the same match can score more than 1 goal. Then I need to devise in the “Matches” table how to assign the amount of goals per player and that by default is one (except when I edit the amount).

Does anyone know of a component within Glide that allows to select with dropdown and then assign number of goals per player? I had thought, first just select players, save and then go back to edit (if necessary) the amount of a player.

The project is hosted at https://audaxitaliano.app/

Any ideas are welcome :slight_smile:


It looks like you are currently using a multi-select choice component to save a list of PlayerIDs.
Whilst that is fine when you only need a store a single attribute, it’s not the best choice for your use case - where you want to store both the PlayerID and the number of goals scored.

What I would recommend here is a small JSON structure. Something like the following:

[
    {
        "player_id": "abc123",
        "goals_scored": 1
    },
    {
        "player_id": "abc456",
        "goals_scored": 2
    }
]
1 Like

Hi Darren, I’m going to try what you say.

As far as I can see, I would have to create a new “number of goals per player” column. The number shown in my image is the total score for example:

AUDAX = 3 goals

Player ID = 2 goals
Other player ID = 1 goal

Currently, I take each player ID as 1 goal only.

How could I set by the interface the amount?

You would most likely need to use a Helper Table to create the JSON structure and allocate the goals for each match, and for extracting the data for display you could either use the Query JSON column or a JavaScript column.

If you’re not familiar with working with JSON in Glide, there is a bit of a learning curve. But there are plenty of tutorials around. Check tutorials posted by either @Robert_Petitto or @Loqode

I understand, I will make a table to feed that information and I will check everything about JSON, thank you very much.

Wouldn’t it be easier for you to create a match first, then have a table where you store each row of Player ID & goals scored, plus the match ID?

1 Like

Yes, that’s a good idea. I will implement a second table with the detail of the match, there I will place player and number of goals scored and then the total sum.

1 Like

I made the separate table, in which I get the “match ID” and “player ID” and the number of goals. The problem I see is that I will generate a large amount of data in this new table, endangering the limits of the current plan (TEAM RO).

I have more than 2,000 matches loaded in the data. Of those 2,000 matches, each one has goals and players. So as an example, if in a match a player scores 3 goals, my new table is injected with 3 rows of data.

I have not been able to see in depth today the idea of creating a JSON and make the query, is it the right way to create a new table of data?

I am sending you a screenshot of the new table with some records loaded.

Another option that occurs to me is that all the players that have a goal by default have a value of “1” (1 goal) and the particular cases that are more than 2 goals I edit them, then the new table would be more compact (If Then).

And then I add up all the values, is this a good idea to avoid bursting the data table?

I need to devise a way to add the “goals” (quantity) in this case when someone visualizes the data of “Ñublense” (a soccer team) should see Gonzalo Ríos (player) with 4 goals.

Any idea how to make this relation or query? I tried with Relation and it associated everything but I couldn’t group and do the sum with Roll.

So it’s for the whole total for the database? You should be able to do that with a relation from the Players table, and rollup the number of goals on top of that relation.