No history yet

Introduction to Databases

What Is a Database?

At its core, a database is just an organized collection of information. Think of it as a digital filing cabinet. Instead of stuffing papers into folders, you store data in a structured way so you can find, update, and manage it easily. Whether it's your contacts list, a company's sales records, or the inventory of a warehouse, a database provides a reliable home for that information.

The main job of a database is to keep data safe and accessible. It ensures that information isn't lost and that multiple people or applications can interact with it at the same time without causing chaos. While there are many kinds of databases, they generally fall into two main categories: relational and non-relational.

Relational Databases

The most common type is the relational database. The 'relation' part just means the data is organized into tables, which look a lot like spreadsheets. Each table stores information about a specific type of thing, like customers or products.

These tables are made up of rows and columns.

  • Columns: A column represents a specific attribute or piece of information, like 'First Name' or 'Email Address'. Every entry in a column is of the same data type (e.g., text, number, or date).
  • Rows: A row represents a single record or item. For example, one row in a 'Customers' table would contain all the information for one specific customer: their name, email, and phone number.

Here’s a simple example of a table that might store information about users:

UserIDFirstNameLastNameEmail
1AlexJohnsonalex.j@email.com
2MariaGarciam.garcia@email.com
3ChenWeichen.wei@email.com

Each row is a unique user, and each column holds a specific piece of information about them. The UserID column uniquely identifies each user, which is a key concept in relational databases. We'll see later how Structured Query Language, or SQL, is the language used to talk to these kinds of databases.

Lesson image

Non-Relational Databases

Non-relational databases, often called NoSQL databases, store data in formats other than tables. Instead of the strict row-and-column structure, they might use documents, key-value pairs, or graphs. This flexibility can be useful for handling large amounts of unstructured or semi-structured data, like social media posts or sensor data.

For example, a user's data might be stored in a single document that contains all their information, including a list of their orders. In a relational database, this would likely be split across a 'Users' table and an 'Orders' table.

For now, we'll focus on relational databases, as they are the foundation for SQL.

Why Databases Matter

You might wonder why we need databases when a simple spreadsheet can also store data in tables. Databases are built for more demanding tasks. They are designed to handle vast amounts of data efficiently and can be accessed by many users or applications at once without corrupting the data.

They also enforce data integrity, meaning they help ensure the information stored is reliable and consistent. For example, a database can prevent you from accidentally deleting a customer record if that customer still has outstanding orders. This level of control and reliability is crucial for almost every modern application, from banking systems to online stores.

Time to check your understanding of these core concepts.

Quiz Questions 1/4

What is the fundamental purpose of a database?

Quiz Questions 2/4

In a relational database table that stores customer information, what does a single row typically represent?

Understanding what a database is and how relational databases are structured is the first step. Next, we'll dive into how to communicate with them.