The world’s leading publication for data science, AI, and ML professionals.

Can I Form A Dream Team in FIFA 19 using SQL?

SQL Is Powerful but Is It Powerful Enough for This Important Job?

Data Analysis Series: An Overview of FIFA 19 Players Dataset

Photo by Bence Balla-Schottner on Unsplash
Photo by Bence Balla-Schottner on Unsplash

Intro

Sql is one of the most important language in data space. Even though there are lots of ways of dealing with data such as within Excel files, XML files, through APIs etc., dealing data within databases is always a big part of our professional lives. Naturally, SQL is the most common way to handle requests within databases. It is a must knowledge if you are interested in data space.

After having the technical introduction, I eager to ask to you;

Do you play football games? 😀

I can hear you all right! Yes, you do 😀 . If you are interested in football games, I am 100% sure that you have played EA’s one of FIFA series once in your life! In this article, we are going to examine FIFA 19’s dataset which you can also find it from this link. I especially choose this data set because I am also one of fans of this game and I love football! Having said that, if you haven’t read the previous article of this series, I suggest you read that as well. In the previous article, I used Tableau data visualization tool in order to find a good striker for my hypothetical team! 😀 Here is also its link.

Objective

My main purpose on this article is to show you how to use SQL language on a dataset in order to get insightful information and results easily. Sometimes I wish that there was a way to write SQL queries within this game so that I can make my player search, maybe, more effectively!

As you understand from the heading of this article, I want to build up my dream team with the help of SQL language using this dataset. To keep things simple, I only want to find my first eleven players. What does that mean? Here what it means; I would like my team’s formation in 4–4–2 and that is why I will need the players whose positions are as follows;

  • One goalkeeper
  • Four defence players
  • Four midfielder players
  • Two strikers

Getting Back to Business

In my analysis, I divided my search into two categories. First, I want to find a goalkeeper, then I will build up the rest of the team at once. However, I need to know which attributes I should pay attention during my search. What are the most important attributes for each position I am looking for? For example, reflex attribute for a goalkeeper is a must. Jumping is very important for a defence player. Stamina is very crucial for a midfielder and finishing attribute for a striker is of course needed all the time.

What attributes do you care most for your team players?

Long story short, I created a short list of attributes for each position that I am looking for. Here is my list;

For my goalkeeper position, I will look the following attributes (as are they written in the databases);

  • GKReflexes
  • GKDiving
  • Positioning
  • GKHandling
  • GKKicking
  • SprintSpeed

For my defence positions including ‘CB’, ‘RB’, ‘LB’ (CB, i.e., Centre Back etc.);

  • Height
  • Jumping
  • Agility
  • LongPassing
  • ShortPassing
  • BallControl

For my midfielder positions including ‘CM’, ‘RM’, ‘LM’ (RM, i.e., Right Midfielder etc.);

  • Work Rate
  • Stamina
  • ShortPassing
  • LongShots

For my striker position;

  • ShortPassing
  • LongShots
  • BallControl
  • Strength
  • Finishing

Besides these position and attribute knowledge we have, contract and value information of players will be key in my scenario. Having these in mind, let’s continue to the SQL part!

Showtime with SQL

Firstly, let’s search for a goalkeeper. For this, I wrote the below SQL code;

What above code does is to search the goalkeepers with the attributes we want in all goalkeepers. The first condition is that these attributes should be above the average. The second condition is value which should be around 10M Euros. After running this query, we have the below result;

GK Results (Image by Author)
GK Results (Image by Author)

Secondly, let’s search our defence players. Here’s the SQL code for it;

In above query, I actually did the same thing with what I did for the goalkeeper search. Here’s its result;

Defence Results (Image by Author)
Defence Results (Image by Author)

However, I do not want to do all these queries every time for each position one at a time. That is why I want to get all results for defender, midfielder and striker positions at once. In order to achieve this goal, I prepared the following SQL query;

Having this query saves us from writing recurring queries. We combined all results in one result table except the result of GK position. After executing this query, we get the following results;

All Results Except GK (Image by Author)
All Results Except GK (Image by Author)

Conclusion

Here comes the answer! Yes, SQL is powerful enough to build up a dream team. However, I cannot make any promise after you build up your team with SQL whether you can win any game 😀 Kidding…

Note: You can also check this blog post and some other interesting topics on my personal web page. Additionally, you can also find me in LinkedIn via this link.

Next: End of Discussion! Not Messi, Not Ronaldo! The Most… Data Analysis with Python


Related Articles