No history yet

Introduction to Databases

What's a Database?

Think of a database as a digital filing cabinet. It’s a system for storing and organizing information so that you can easily find it later. Instead of paper files, it holds data in a structured way on a computer. The main purpose is to manage large amounts of information efficiently, making it simple to add, update, remove, or retrieve data whenever you need it.

Whether it's the contact list on your phone, the inventory system for an online store, or the records at a doctor's office, databases are the invisible engines powering much of the digital world. They ensure that data is not only stored safely but is also readily available and consistent.

Types of Databases

Not all data is organized the same way. Over the years, different types of databases have been developed to handle different needs. The two most common categories you'll encounter are relational and NoSQL.

Relational Databases are the most traditional type. They organize data into tables, much like spreadsheets. Each table has rows and columns, and the tables can be linked to one another based on related data. They are highly structured and reliable, making them great for things like financial transactions or customer records.

NoSQL Databases (which stands for "Not only SQL") are more flexible. They don't always use tables and can store data in various ways: as documents, key-value pairs, or graphs. This makes them ideal for handling large amounts of varied or unstructured data, like social media posts, sensor data from IoT devices, or user profiles.

FeatureRelational (SQL)NoSQL
StructureRigid, predefined (tables)Flexible, dynamic
Data ModelTables with rows and columnsDocuments, key-value, graph
Best forStructured, consistent dataLarge, unstructured data
ExampleCustomer order historySocial media feed

Anatomy of a Relational Database

Since relational databases are so common, let's break down their key parts. Understanding these components is essential for working with most data systems.

Table

noun

A collection of related data entries organized in rows and columns. For instance, you might have a table for customers and another for products.

Schema

noun

The blueprint of the database. It defines the structure of each table (the column names and data types), and the relationships between tables.

The real power of relational databases comes from relationships. This is how different tables are connected. For example, a Customers table might store customer information, and an Orders table would store all the orders. A relationship links a specific customer to all the orders they've placed. This avoids duplicating customer information for every single order and keeps the data clean and efficient.

Talking to Databases with SQL

How do you actually ask a database for information? You use a special-purpose language. For relational databases, that language is SQL (Structured Query Language).

SQL lets you write queries to perform actions like retrieving, adding, updating, or deleting data. It's the standard way to communicate with most relational database systems.

An SQL query is made up of commands, called statements. Let's look at a basic example. Imagine we have a Products table and want to find all the products that cost more than $50. The query would look like this:

SELECT Name, Price
FROM Products
WHERE Price > 50;

Let's break that down:

  • SELECT Name, Price tells the database which columns we want to see.
  • FROM Products specifies the table we're looking in.
  • WHERE Price > 50 sets a condition to filter the results, so we only get rows where the price is greater than 50.

Even with just these three commands, you can perform powerful searches to pinpoint the exact data you need.

Quiz Questions 1/5

What is the primary purpose of a database?

Quiz Questions 2/5

What are the two most common categories of databases mentioned in the text?

That's a quick tour of the basics. Understanding what databases are, how they're structured, and how to talk to them is a fundamental skill in any data-related field.