Before we dive into writing actual SQL queries, let me give you a quick tour of how databases work. Trust me, this will make everything else click much faster.
A database is basically a collection of tables. If you have ever used Excel or Google Sheets, you already understand 80% of the concept. Tables have rows and columns. Columns are the categories (like name, age, email), and rows are the actual data entries.
Relational Databases
The kind of databases SQL works with are called relational databases. Fancy word, simple idea โ it means your data is split across multiple tables that are connected to each other through relationships.
For example, in a school database you might have:
- A
studentstable with name, age, and student ID - A
coursestable with course name and code - An
enrollmentstable that links which student is taking which course
Instead of putting everything in one giant messy table, you split it up. This is called normalization, and it is one of those things that sounds complicated but is really just common sense once you see it in action.
Popular Database Systems
SQL is the language, but there are different database systems that use it. They all speak SQL, but each has its own little quirks. Here are the ones you will most likely run into:
- MySQL โ Very popular for web applications. Free and open source.
- PostgreSQL โ Advanced features, also free. A lot of developers swear by it.
- SQLite โ Lightweight, no server needed. Great for learning and small projects.
- Microsoft SQL Server โ Used a lot in big companies.
- Oracle โ Enterprise stuff. Powerful but expensive.
For this tutorial, the concepts apply to all of them. I will point out when something is specific to one system.
How We Will Learn
Here is my approach โ I am not going to dump a million facts on you. We will learn by doing. Each lesson introduces one concept, shows you examples, and then you can try it yourself using our SQL compiler.
By the end of this tutorial, you will be able to create your own database, fill it with data, ask questions about that data, and understand how the apps you use every day work under the hood.