What is SQL?
Structured Query Language, or SQL, is a standard ANSI/ISO language for accessing and manipulating data stored in relational databases.
A relational database is a type of database which stores data in structured manner, in a table with columns. Each column can store a specific data type such as a string, an integer, a boolean, etc., or it can be linked (i.e. "related") to other tables within the same database through a key (usually an id) that is present in both tables. The key is called the primary key in the connected table and the foreign key in the connecting table.
For example, we have a table
school_class_8b that contains the students in class 8b and their average grade (in percentage) in each subject that they study.
| student_id | mathematics | english | science | physical_education | | ---------- | ----------- | ------- | ------ | ------------------ | | 123 | 70 | 83 | 54 | 67 | | 234 | 63 | 67 | 75 | 98 | | 345 | 34 | 78 | 87 | 92 |
Additionally, we have another table
students which holds information about every student in the school.
| student_id | f_name | l_name | year_of_birth | address | |------------|--------|----------|---------------|-------------------| | 123 | John | Doe | 2001 | 67 Baker Str. | | 234 | Maria | Santiago | 2001 | 98 Roberttown Ln. | | 789 | Jane | Doe | 2000 | 8 Sunnybank Rd. |
The tables are connected through the
student_id key, which appears in both tables, and it serves as primary key in the
students table and as foreign key in the
Some of the most popular database management systems that use SQL are Oracle, MySQL, Microsoft SQL Server and PostgreSQL.
Why should you learn SQL?
SQL was introduced in 1974 and has come a long way since. Currently, it is the most widely used languge for quering data, and there is a high chance that you stumble upon it in your workplace, even if your job does not directly involve working with data.
Due to its popularity, SQL has been adopted in many database management systems and tools for analysis on large datasets. Although SQL knowledge is an essential tool frequently implemented by data analysts and data scientists, you will still benefit from knowing at least basic SQL, even if you are not a data analyst, as it will help you understand how a database is structured and how you can acquire certain pieces of information inside it. Additionally, you will be able to communicate more effectively with your colleagues who work directly with data.
In practice you might use an ORM framework (a.k.a. Object Relational Mapper) which will provide easier syntax; however, under the hood, it still builds an SQL statement based on your input. Therefore, having proper understanding of how SQL works can help you use the framework features more efficiently and select the quickest way to access the data you need.
Top 5 Websites to learn SQL
Recently I have started learning SQL and I want to share with you the resources that
I have found most useful to me.
In my opinion, Mode and SQLBolt are the best resources because they both offer great explanations with clear examples and some practice questions after each article to help you use active recall for better memory retention.
W3Schools is another great choice for obtaining information regarding the use of SQL, as the articles there are written concisely and provide good summaries of the information, which I find super useful for revision and for later reference. However, from my perspective, the practice questions were too simple and therefore less useful than the ones in other websites.
DataLemur is a website that provides interview questions for data scientists and naturally, it includes more complex problems, some of which require additional knowledge in statistics as well. Fortunately, each question is marked as easy, medium or hard, so that you can select the problems that suit your level of knowledge.
I do recommend this website for people with intermediate knowledge, though, since even the easy practice problems might be a little too challenging for complete beginners.
Lastly, Javatpoint provides very detailed articles and clear examples; however, it offers no practice questions. If your learning style is not dependent on solving problems after each new topic, Javatpoint is still a great resource for learning SQL.
SQL has been here for more than three decades, and it is still in demand in many data-related areas of industry. Due to its applicability, versatility, and user-friendliness, SQL is the most popular language for data querying and manipulation. Learning it can have numerous benefits, including having a clear idea of how data is structured,
accessed, and modified, being able to quickly learn frameworks that are based on SQL; and improving performance by constructing fast and efficient query statements.
Top comments (0)