Welcome to the World of Databases!

In this chapter, we are going to explore how computers keep track of massive amounts of information. Think about Netflix, Instagram, or your school’s grading system. They all have millions of pieces of data to manage. How do they keep it organized so they can find exactly what they need in a split second? The answer is Relational Databases.
Don't worry if this seems a bit technical at first—we’ll break it down piece by piece using examples from everyday life!

5.1 Data and Information

Before we build a database, we need to understand the difference between Data and Information. These two words are often used interchangeably, but in IT, they mean very different things.

Data vs. Information

  • Data: These are raw facts and figures with no context. For example: "12052008". On its own, it’s just a bunch of numbers.
  • Information: This is data that has been processed or organized so it makes sense. If we add context to that number, it becomes: "The student’s date of birth is 12/05/2008."

The Analogy: Imagine a pile of flour, eggs, and sugar sitting on a table. That is Data. Once you mix them and bake them into a cake, you have Information. The cake is the useful result!

Structured vs. Unstructured Data

Not all data looks the same. Structured data is very organized (like a spreadsheet with clear rows and columns). Unstructured data is everything else—emails, photos, videos, and social media posts. It is much harder for a computer to "read" unstructured data quickly.

Key Takeaway: Organisations value databases because they allow them to turn messy data into meaningful information that can help them make better decisions.


5.2 Structured Data: The Relational Database

A Relational Database is a way of storing data in multiple tables that are linked (related) to each other. This prevents mistakes and keeps everything tidy.

The Anatomy of a Table

To understand a database, you must understand the parts of a table:

  • Table: A collection of data about a specific "thing" (like a "Students" table or a "Books" table).
  • Field (Column): A single characteristic of the data. For example, First Name or Phone Number.
  • Record (Row): All the data about one specific item. For example, one row in a "Students" table would contain the ID, name, and address for one specific person.

The "Keys" to Success

In a database, we need ways to identify and link data. We use special fields called Keys:

1. Primary Key: This is a field that is unique to every record. No two records can have the same Primary Key.
Example: Your Student ID number or a Passport number.

2. Foreign Key: This is a field in one table that is the Primary Key in another table. This is how we link two tables together!

3. Composite Key: Sometimes, one field isn't enough to be unique. A Composite Key uses two or more fields together to create a unique ID.
Example: In a "Classroom Booking" table, "Room Number" isn't enough (the room is used many times). But "Room Number" + "Time" + "Date" together make a unique record.

Quick Review Box:
- Field = Column (Category)
- Record = Row (Individual item)
- Primary Key = The unique ID number.


5.2.3 Entities and Relationships

In database design, an Entity is simply the "thing" we are storing data about (like a Customer, a Product, or a Car). The Relationship is how those entities interact.

The Three Types of Relationships

1. One-to-One (1:1): Each record in Table A relates to only one record in Table B.
Example: Each Person has only one Passport, and each Passport belongs to only one Person.

2. One-to-Many (1:M): One record in Table A can relate to many records in Table B.
Example: One Mother can have many Children, but each child has only one biological mother.

3. Many-to-Many (M:M): Many records in Table A relate to many in Table B.
Example: Students and Subjects. One student studies many subjects, and one subject is studied by many students.

Entity Relationship Diagrams (ERDs)

An ERD is a drawing that shows how these tables link together. It uses boxes for Entities and lines to show how they are connected.
Did you know? In an ERD, we often use a symbol called a "Crow's Foot" (which looks like a fork) to show the "Many" side of a relationship!

Common Mistake to Avoid: Don't confuse Primary Keys and Foreign Keys. Remember: The Primary Key is the "Master ID" in its own home table. When it goes to visit another table to create a link, it becomes a Foreign Key.


5.3 Structured Query Language (SQL)

Once we have our data organized in tables, how do we talk to the database? We use a language called SQL (pronounced "Sequel").

Why use SQL?

SQL allows us to manipulate data. This means we can:

  • Select: Find specific data (e.g., "Show me all students who got an A").
  • Insert: Add new data (e.g., "Add a new student to the system").
  • Update/Amend: Change existing data (e.g., "Change a student's address").
  • Delete: Remove data.

Linking Tables with SQL

One of the most powerful things about SQL is the JOIN command. This allows the computer to look at two different tables and combine them into one view based on their linked keys.
Example: Joining the "Orders" table and the "Customers" table so a shop can see which person bought which item.

Memory Aid (SQL Keywords):
Think of S.F.W. to remember the basic order of a query:
Select (What do you want to see?)
From (Which table is it in?)
Where (What is the specific search criteria?)


Summary Checklist

Before you move on, make sure you can answer these:

  • Can I explain the difference between data and information?
  • Do I know that a Primary Key must be unique?
  • Can I identify Fields and Records in a table?
  • Can I explain a One-to-Many relationship using an example?
  • Do I understand that SQL is the language used to search and change a database?

Great job! You've just covered the core concepts of Relational Databases. Keep practicing identifying these parts in the apps you use every day!