We cannot deny that data is a powerful tool for everyone who manages products. We know that companies must use their data to manage their business and make the decision process easier.
For these decisions to be made by data, we first need to manipulate the data in order to obtain the necessary information. As a means to do this, SQL enables us to manipulate the database for reporting and analysis.
In this text, let’s explore SQL and better understand the possibilities we get when we use it in our daily lives.
What is SQL?
SQL is an acronym for Structured Query Language and is also called “sequel” by some people. SQL is a standard language used to work with relational databases. Through it, we can interact with databases through queries to the tables in question.
SQL is the most widely used query language in the world. It has become the industry standard and functions as a “universal language” that works relatively similarly among the major relational databases on the market.
It is worth noting that each database has its own characteristics, but the variations are quite small and allow knowledge of SQL to be used generally.
The tables
We take one step back first to take two steps forward. Simply put, data is stored in tables. Just like the data in your spreadsheets, your company’s data is stored in tables on Amazon, Google, or Oracle servers.
In these cases, we have relational-type databases, a set of multiple sets of data organized by columns, tables, and records. Each table is known as a ‘relation’, and the data stored as tables has its own number of columns and rows and represents a data set.
In a relational database, these tables can communicate based on specific database fields, known as keys.
How does this SQL thing work?
Imagine the database as the big information keeper of your company and SQL as the way you request this data from it.
The request for data from a table works through commands called “queries”. These commands, passed in a few lines of code, tell the database which tables we want to access, what data we need from these tables, and whether we have any conditionals or filters for this query.
In response, the database returns a result in table format.
Basic SQL syntax explained
In SQL we have a few main commands that will be used to construct our queries. Here are the main clauses that you will use:
SELECT: This is used to select data from a database. It will tell you what data we are interested in from a given table.
FROM: This will define the table that contains the fields listed in the SELECT clause.
WHERE: This is basically a filter. The WHERE specifies field criteria that must be met by each record to be included in the results.
ORDER BY: Here we have an order of the results. It will specify how to sort the results obtained in the query.
GROUP BY: This clause has the purpose of grouping the results we obtained. In a query where, for example, we are looking for a company’s workforce, we could group the results by company sectors through GROUP BY.
Some examples
Let’s take a look at some examples of queries that we might need to run in a product routine.
Example 1: I need to access the names of people from the customer's table.
//Query example 1:
SELECT name
FROM customers;
Notice how we are first saying what we want with the SELECT, and then we declare where it is coming from with the FROM.
In the SELECT I say what data I want and in the FROM I will say where this data is coming from.
Let’s go to another example, now using the WHERE.
Example 2: I need to access the name and date of birth of people from the customer's table. Only now I want the people who were born in Brazil (considering that we have this data in the table.
//Query example 2:
SELECT name, birth_date
FROM customers
WHERE birth_place = 'BRASIL';
Notice that to filter the country using the WHERE clause, we specify the column followed by the condition using the ‘=’ symbol, known as the equal operator.
In this case, we are saying that we want to return only those records that match the criteria passed in the query.
In query construction, you can use several logical operators. They work as connectors that will determine the way your query will be done.
There are many logical operators that can be used. Then you can go to this link and explore them a bit better.
What you can do with SQL
Through the SQL language, it is not only possible to read tables, but we can also create, retrieve, update and delete data from a database.
In banks where we can perform all these actions, we have the possibility of CRUD. This stands for Create, Read, Update, Delete.
As product managers, we are mainly concerned with the ability to read information from a database to extract reports and analyses. Let’s leave the creation and use of the other CRUD methods to the data engineers and analysts.
So it stands to reason that even with the most basic SQL skill base, you can create reports by combining tables from multiple databases — and cut out the hassle of having to ask someone else to get the data for you — so that you can get what you need — and get on with your day.
Conclusion
Learning SQL will teach you how to manipulate data to get the information you require. You will learn how to interact directly with your database.
I am sure your staff will feel extremely grateful if you can gather the data on your own without disturbing them. Don’t forget to ask them for access and to check their permissions.
See you in the next post.
You can send me suggestions for text subjects on my personal Linkedin. Subjects that you have doubts about in the technical or product area.
I will do my best to deliver the best article as briefly and succinctly as possible.
Please feel free to bring your questions.
The Technical PM is a FREE newsletter for those who are looking to develop technically in product management and expand themselves further.
Subscribe HERE: https://thetechpm.substack.com/subscribe?
If you enjoyed reading this post, feel free to share it with friends!