Demystifying SQL 101: A Beginner's Journey
What is SQL?
- Drawers (where you may store the underwear and the socks)
- Shelfs (where you store the pants and t-shirts)
- Hanger rods (where you store your shirts and your coats)
SQL Community
- Database Administrators (DBA): they use SQL to manage, maintain and optimise databases.
- Data Analysts: they use SQL to query and analyze data to extract insights and generate reports.
- Business Analysts: they use SQL to query and analyze data to identify market trends and make data-driven business decisions.
- Data Scientists: they use SQL to retrieve and process data for machine learning, statistical analysis, and modelling.
- Data Engineers: Data engineers use SQL queries to transform and prepare data for storage, analytics, and reporting.
- Web Developers: SQL is used in web development to retrieve and display dynamic content in a website. Have you ever use a filtering option or a search feature in a webpage? Well, they may be using SQL in the background to filter the results and only show you products that meet the request.
SQL Dialects
- Transact-SQL (T-SQL): it is used with Microsoft SQL Server
- MySQL SQL: used with MySQL and MariaDB
- SQLite SQL: used with SQLite
- PostgreSQL SQL: used with PostgreSQL
- DB2 SQL: used with IBM Db2
- HiveQL: used with Apache Hive
- Spark SQL: used with Apache Spark
![]() |
Desert with multiple paths as an analogy of SQL having distinct dialects. |
Is SQL a programming language?
- Syntax and Semantics: programming languages have a well-defined syntax and a set of rules for writing code. Programming languages have a well-defined syntax, which includes rules for writing code, keywords, operators, functions, etc. And if you are wondering, yes, SQL has a well-defined syntax and semantics.
- Data Types: the type of values that can be stored in a program, such as numbers, strings, date, and booleans. SQL has data types for defining the type of values that can be stored in a database.
- Variables: variables are basically a named space in memory that can store values (numbers, text, etc.) Some SQL dialects support variable declaration.
- Operators: these are symbols used to perform specific operations, such as arithmetic operators (addition, subtraction, multiplication, etc.), comparison operators (greater than, less than, equal to, etc.), and logical operators (AND, OR). SQL includes these operators.
- Control Structures: Statements used to control the flow of a program, allowing the program to do some of the following:
- Conditional Statement - make decisions (execute part of the code only if a condition is met). This is usually known as IF statements.
- Looping Statements - loop or iterate (execute part of the code multiple times until a condition is met). Usually known as FOR and/or WHILE loops.
- BREAK statement - stop the program (if a condition is met)
- Data Manipulation: it is the ability to handle and modify data in various ways. SQL is limited to SELECT, CREATE, INSERT, DELETE or UPDATE tables from databases only.
- Libraries: programming languages have libraries to develop applications. Libraries are a collection of pre-written code that can be used to perform a task. Libraries are reusable and allow developers to save time and effort. SQL have specific libraries used for database-related task only, and commonly, these libraries are used to provide connectivity with a specific database management system (such as MySQL, PostgreSQL, Oracle, and SQLite). An example of these libraries is when you use Python to develop a program and need to connect to a PostgreSQL database with user information for authentication; to achieve this, you need to use use the psycopg2 Python library to connect to the database and be able to authenticate the user.
- Application Development: programming languages can be used to develop web applications, software, games, mobile apps, etc. SQL is often used within applications to interact with a database, although SQL is not suitable to build an application alone, it can only be used to query and manipulate data from a database.
How to use and where to practice SQL?
For me, SQL Fiddle or DB Fiddle are the number 1 tools to use if you are new to the SQL world. They are FREE ONLINE sites where you are able to test and share SQL queries in different SQL dialects (MySQL, PostgreSQL, and SQLite). In the next posts we will cover some basics of SQL and explain how to use SQL Fiddle and DB Fiddle.
I like to recommend these tools first as when you are learning you will be faced with multiple SQL dialects, which may require you to install the DBMS specific software to use them; and if you are unsure of which dialect you want to learn you may need to download and install all these different DBMS in order to use the different SQL dialects. With SQL Fiddle and DB Fiddle you can test and share SQL queries in various SQL dialects.
Comments
Post a Comment