SQL Fundamentals from Scratch
Introduction to Databases
Organizing Information
At its core, a database is just an organized collection of information. Think of it like a digital filing cabinet. Instead of paper folders, you have a system designed to store, manage, and retrieve data quickly and efficiently. Nearly every app you use, from social media to your banking app, relies on a database to function.
The main purpose of a database is to bring order to data. By storing information in a structured way, we can easily find specific pieces of information, update them, and analyze them to find patterns. Without databases, managing the massive amounts of data in modern applications would be nearly impossible.
Relational Databases
The most common type of database is the relational database. The name comes from the way it organizes data: in tables that can be related to one another. A system that manages these databases is called a Relational Database Management System, or RDBMS.
Imagine you have two separate lists. One lists all your customers. The other lists all their orders. A relational database allows you to connect, or relate, these two lists using a common piece of information, like a customer ID. This way, you can easily see which customer placed which order.
This model of related tables is incredibly powerful. It prevents you from having to duplicate information and keeps your data consistent and reliable. SQL, the language you're about to learn, is specifically designed to work with relational databases.
The Building Blocks
Relational databases have a simple, clear structure based on three key components: tables, columns, and rows.
Table
noun
A collection of related data held in a structured format within a database, consisting of columns and rows. It's often called a relation.
A table is organized around a single topic. For instance, in a university database, you might have a table for Students, another for Courses, and a third for Professors.
Column
noun
A vertical set of data values of a particular type, one for each row of a table. It's also known as an attribute.
Columns define the properties of the data in a table. In our Students table, the columns might be StudentID, FirstName, LastName, and Major. Each column is set up to hold a specific type of data, like a number, text, or a date.
Row
noun
A single, implicitly structured data item in a table. It represents one record within the table. It's also called a record or tuple.
Rows are the actual records. If columns are the template, rows are the information you fill in. One row in the Students table would contain the StudentID, FirstName, LastName, and Major for one specific student.
| StudentID | FirstName | LastName | Major |
|---|---|---|---|
| 101 | Maria | Garcia | Biology |
| 102 | Chen | Wei | Computer Science |
| 103 | Fatima | Khan | History |
In the table above, Students is the table name. StudentID, FirstName, LastName, and Major are the columns. Each line of student data is a row.
What is the primary function of a database?
In a relational database, what is the term for a single topic or entity, such as Students or Products?
This structure is the foundation of every relational database. Understanding it is the first step to mastering SQL.
