Learning how to Learn–An experimentation with SQL

Sneha Mehrin
The Startup
Published in
8 min readJan 24, 2021
Photo by Scott Graham on Unsplash

If you are an aspiring data analyst or data scientist, you already know SQL is one of the basic skill sets you should have.

But if you are like me, you probably would have scoured the internet on becoming an expert in SQL and still cannot use this powerful tool efficiently at work.

Most resources on the internet would give you a boilerplate template to study SQL —

a) Attend some courses.

b) Do some problems.

But do you know why this approach fails in an actual work setting? Before we go into that, take a minute to answer the below questions.

  • Can you build a pipeline that is stable, robust, and performance-optimized?
  • Can you look at an issue and immediately pinpoint the source of the problem?
  • Can you gauge the feasibility of your stakeholder’s requirement on the spot?
  • Can you ask follow-up questions immediately to mitigate potential issues in the future so that you don’t waste precious time by booking another meeting?

If you answered no to these questions, then you need to read the rest of the article.

Most people say we can only answer these kinds of questions with experience-I disagree. Throughout my career, I have been working as a consultant helping developers design pipelines. I only built full-fledged pipelines from scratch last year.

My ability to mitigate issues or figure out what would work best didn’t come by taking courses or through experience, it came by learning the right way.

In this article, I want to share some of my techniques that I used over the years to gain intermediate-level knowledge of SQL

My Learning Map

Having been a lifelong learner, the key lesson I have learned is to never attempt to learn without having a map.

One of my key techniques to learning any skill is dividing it into milestones. Milestones keep me motivated and stay on track. This way, even if I do not reach my end goal, I still would have picked up a lot of valuable skills along the way.

Here is a quick snapshot of my learning map for SQL. You can use this for any skill that you want to learn.

Let’s look at how I tackle each milestone. I will be covering Milestone1 & Milestone 2 in this article.

Milestone 1: Research & Theory

It is critical to dip your toes in the water before you take a deep-dive into the subject if you are a first-time learner.

Ideally, spend at least 5% of your total time on research & 10% of your time in theory.

Meta-Learning -Learning about Learning

If you are planning to buy a house, do you buy the house first and see how it feels like, or would you talk to your peers or people who have already bought the house to see how the experience was like? You should do the same thing for learning a subject as well.

My main mantra in this section is below :

a) How do others learn SQL?

All our lives we have been learning from others- so why should this be any different? Start your learning process by searching how other people have learned SQL.

The most common themes would involve taking a particular Udemy course, reading some specific books & attempting problems from a site like Leet Code or Hacker Rank.

Read about 5–10 articles and note recurring themes.

If 10 people say a particular Udemy course is better, then that needs to be your starting point

b) How is SQL used in the industry by your peers?

Before you invest 100 hours of your time, you need to know if you are even going to like SQL.

Some people like programming more than SQL or you might not even need an expert level of knowledge in your industry. Informational interviews will help you determine the level of expertise needed and the time you should invest in it.

Talk to Database administrators, data analysts, or data engineers and figure out how they use SQL on a day-to-day basis.

Ask them questions such as: How does their day look like? What problems do they tackle every day? Do they enjoy their work?

Once you understand how people in your industry use SQL, you can tailor your learning to your needs.

c) What fascinates you the most?

At this stage, you have an excellent picture of what excites you the most about SQL.

Remember: Your goal is to become an expert in solving problems in your domain using SQL and not to master the entire tool itself — So use your time wisely.

What got your heart pumping when you talked to your peers?

Is it building pipelines? — Then you need to focus more on performance optimization along with programmatic SQL.

Is it data analysis?- Then probably you can get away with some basic querying and window functions.

Figuring out which problems excite you the most will help you in picking the right resources to learn.

d) Gather Resources

Once you know what you need to learn, google for the best resources around that topic. If you want to learn performance optimization, then attend the best course or buy the best books on that topic.

Let’s look at how I use this method to create my learning plan

e) Learn the theory

Get the theoretical part of the way by only studying the bare minimum. If you are a complete beginner, spend at least 10–15 hours learning the basics of SQL.

You can either use a course or a book to help you achieve the same. If you are an intermediate practitioner, then move on to Milestone 2.

Milestone 2: Practice SQL

This is where the meat of our learning comes in. How you spend your time learning in this phase will define your mastery of this subject.

1. Mental Representation for each problem

Like most of you, my only aim in the beginning while practicing problems was to just get the correct answer. While there is nothing wrong with doing that, I realized it was just a mechanical way of doing things. Sure, you can get by with this approach, but you wouldn't be reading this article if that was your aim.

Repeated practice will not make you an expert, but deliberate practice will.

My entire learning process changed when I stumbled across this concept of Mental Representations.

Now, what does this mean?

Mental representations are how your brain stores information about a particular topic.

Every problem in SQL is a way for you to build on your mental representation toolkit. Think of it as a way for you to visualize the problem at the most fundamental level.

How did I build my mental representation in SQL?

For every problem, I dissect the logic into specific steps and visualize them as tables.

For example: Let’s say your problem is to find the departments of the Teachers.

Most of you will immediately start writing the SQL Code. I, however, make my own examples and draw them out as tables.

This might seem very redundant for you, but trust me, it becomes very effective in complicated situations. This is the way you can come up with a solution on the spot and identify pitfalls even before coding them.

Start with 10 simple questions, and for every problem draw out each step of your solution as tables.

As you do this, you will understand concepts such as joins, window functions ,pivot,case statements more clearly. Your logic and reasoning will improve radically. Try it out!

2. Analyze 3 other solutions

Solving problems using mental representation will definitely improve your understanding of the concepts, but the secret to mastery is not in your solution, it is in decoding other people’s solutions.

If you have only one tool in your arsenal, you will attack every problem with the same tool. If you know joins best, you will try to solve every problem using joins. So, if you want to be an expert, then put aside your ego and expand your thinking by decoding other people’s solutions.

Remember, your goal shouldn’t be to solve a problem, it should be to solve it in the best possible way.

After figuring out a solution to the problem using my logic, I set aside 15 minutes to look at the 3 best solutions in Leetcode.

3. Drill down into concepts you are unfamiliar with.

When you do the step above, you will come across certain techniques which you didn’t notice in any book or course. If you want to be exceptional, drill deep down into those topics which you are unsure of.

Let me give you an example, I am more comfortable with joins and window functions, so I used to do every problem the same way. But I found people using pivot statements and sub-query in innovative ways. So I set aside some time to learn these topics in a detailed way (Make sure you use mental representations while learning new topics).

I also make it a point to attempt the next problem using the tricks I learned previously. This way I improve my level of understanding iteratively and add different tools to my skill set.

4. Challenge yourself to the next level.

Following the above 3 steps for 10 simple questions will improve your knowledge of SQL substantially in less than 10 hours.

So the next step is to challenge yourself by moving on to 10 Medium questions.

Do the same set of activities for 10 Medium questions on Leet code.

To Summarize

  1. Attempt the problem on your own by creating a mental representation for each step of the problem.
  2. Look at the 3 best solutions from other people.
  3. Drill down into specific concepts you didn’t know.
  4. Advance to the next level and repeat the same steps.

Now you are on a roll, after 10 medium questions move on to 10 Hard questions and attempt all the leet code questions in the same way.

This entire process will take you more time than just solving problems on your own. But this way of learning will make you much more successful in a real-life situation. You will learn which technique to use in any situation. You will visualize solutions in your mind and come up with innovative questions to tailor them according to your client’s need.

Reach out to me if you need more clarifications on how to solve SQL using Mental Representations.

--

--