No history yet

Introduction to Databases

What is a Database?

Think of a database as a highly organized digital filing cabinet. Instead of manila folders, it uses a structured system to store, manage, and retrieve information quickly and efficiently. From your phone's contact list to a massive e-commerce site's inventory, databases are the invisible backbone that powers much of the modern world.

The primary purpose is to keep data organized, consistent, and accessible. Imagine a company with millions of customers. A database ensures that when a customer service agent looks up a customer's order history, they get the correct, up-to-date information in seconds. Without a database, that data would be a chaotic mess, likely spread across countless spreadsheets.

At its core, a database is a structured collection of data stored electronically.

Relational Databases

The most common type of database is the relational database. The 'relational' part is key: it means the data is stored in a way that recognizes relationships between different pieces of information. This system is managed by a Relational Database Management System, or RDBMS.

In a relational database, information is organized into tables, much like spreadsheets. The real power comes from the ability to link these tables together. For example, a business might have one table for customer information and another for their orders. A relational database allows you to connect a specific customer to all the orders they've placed.

The Building Blocks

Relational databases have a simple, clear structure based on three core components: tables, rows, and columns.

Table

noun

A collection of related data held in a structured format within a database. It consists of columns and rows.

Think of a table as a single spreadsheet in a workbook. A database can contain many tables, each one dedicated to a specific type of information, like Customers, Products, or Orders.

Column

noun

A vertical field in a table that contains all of the information for a specific attribute.

Row

noun

A single record or entry in a table, representing a complete set of information for one item.

Connecting the Dots with Keys

How do we link tables together? The answer is keys. Keys are special columns that create relationships between tables and ensure data integrity.

A Primary Key is a column (or a set of columns) that uniquely identifies each row in a table. Think of it as a student ID number or a social security number. No two rows in the same table can have the same primary key value.

A Foreign Key is a column in one table that is the primary key of another table. It's the 'glue' that connects related data. For instance, an Orders table would likely have a CustomerID column. This CustomerID is a foreign key that points to the primary key in the Customers table, linking each order to the customer who made it.

Basic Database Operations

Regardless of the database system, there are four fundamental operations you can perform on data. These are often referred to by the acronym CRUD.

OperationAcronymDescription
CreateCAdd new data (a new row) to a table.
ReadRRetrieve or fetch data from one or more tables.
UpdateUModify existing data within a table.
DeleteDRemove a row of data from a table.

These four operations are the foundation of almost everything you do with a database. Whether you're signing up for a new service (Create), checking your bank balance (Read), changing your address (Update), or closing an account (Delete), you're using CRUD operations.

Now that you understand these core concepts, you're ready to start exploring how to interact with databases using languages like SQL.

Quiz Questions 1/5

What is the primary purpose of a database?

Quiz Questions 2/5

In a relational database, what is the main function of a foreign key?