No history yet

Introduction to Databases

What Is a Database?

Think of a database as a digital filing cabinet. It's a structured collection of information, organized so you can easily access, manage, and update it. Instead of paper files, you have digital data. The main job of a database is to store information efficiently and make it available when needed.

Database

noun

An organized collection of structured information, or data, typically stored electronically in a computer system.

Almost every app you use relies on a database. Your social media feed, your banking app, and your favorite online store all use databases to keep track of users, posts, products, and transactions. Without them, finding a specific piece of information would be like searching for a needle in a digital haystack.

Two Main Flavors

Databases come in many shapes and sizes, but they generally fall into two main categories: relational and non-relational.

Relational databases are highly structured, like a perfectly organized spreadsheet. Non-relational databases are more flexible, like a folder that can hold different types of documents.

A relational database stores data in tables, which are connected to each other through relationships. This model is very common and is the foundation for systems like MySQL. It's great for handling structured data, where every piece of information fits neatly into predefined categories.

A non-relational database, often called NoSQL, stores data in a format other than tables. This could be as documents, key-value pairs, or graphs. They offer more flexibility and are often used for large sets of data that don't have a rigid structure, like user-generated content or data from sensors.

The Relational Model

Since we're building up to MySQL, let's focus on the relational model. This model organizes data into tables, which are the fundamental building blocks.

The foundation of an RDBMS is based on the relational model, which organizes data into tables (relations) consisting of rows (tuples) and columns (attributes).

A table is a collection of related data held in a table format. Think of it as a single sheet in a spreadsheet file.

A column represents a specific attribute or piece of information, like 'First Name' or 'Email Address'. Each column has a defined data type, such as text, number, or date.

A row is a single record in a table. It contains the actual values for each column, representing one specific item. For example, one row in a 'Users' table would contain all the information for a single user.

UserIDFirstNameLastNameEmail
1AliceSmithalice.s@example.com
2BobJohnsonbjohnson@example.com
3CharlieBrowncharlie@example.com

In this example, 'Users' is the table. 'UserID', 'FirstName', 'LastName', and 'Email' are the columns. Each numbered line is a row, representing one user.

Databases are essential because they provide a reliable and systematic way to manage data. They ensure data integrity, meaning the information stays accurate and consistent. They also make it possible for many users to access and modify data at the same time without creating conflicts.