Welcome to Topic 5: Data and Databases!

In this chapter, we are going to explore how the digital world handles its most valuable asset: Data. Think of data like the "gold" of the 21st century. Whether it is your Instagram likes, your school grades, or a bank's list of transactions, it all needs to be stored, organized, and found quickly. By the end of these notes, you’ll understand how databases work and how we use a special language called SQL to "talk" to them. Don’t worry if some of the terms sound technical at first—we’ll break them down together!


5.1 Data and Information

People often use the words "data" and "information" as if they mean the same thing, but in Information Technology, they are very different!

5.1.1 The Difference Between Data and Information

Data consists of raw facts and figures that have no meaning on their own.
Example: 19052006 (This is just a string of numbers).

Information is data that has been processed, organized, or structured so that it makes sense to people.
Example: 19/05/2006 (Now we know it is a date of birth).

The "Cooking" Analogy:
Think of Data as raw ingredients (flour, eggs, sugar). On their own, they aren't very useful. Information is the cake you get after you process and "cook" those ingredients!

5.1.2 Structured and Unstructured Data

Not all data looks the same. We generally put it into two "buckets":

1. Structured Data: This is data that is highly organized and fits neatly into fixed fields or tables. It is very easy for computers to search.
Source Example: An Excel spreadsheet or a library catalog.

2. Unstructured Data: This is "messy" data that doesn't have a pre-defined format. It is much harder for computers to organize and search.
Source Example: Social media posts, emails, videos, or voice recordings.

5.1.3 The Value of Extracting Meaning

Why do organizations spend so much money on data? Because extracting meaningful information allows them to make better decisions.
Example: A supermarket looks at "data" (items sold) to find "information" (which snacks are most popular in June) so they can stock more of them and make more profit.

Quick Review Box:
- Data: Raw facts (ingredients).
- Information: Processed facts (the cake).
- Structured: Organized (tables).
- Unstructured: Messy (emails/videos).


5.2 Structured Data (Relational Databases)

To keep structured data organized, we use Databases. Specifically, we use Relational Databases, which store data in tables that are linked together.

5.2.1 Why use a database?

Imagine trying to find one student's phone number in a pile of 5,000 unorganized papers. It would be a nightmare! Databases allow us to store massive amounts of data, find specific items in milliseconds, and ensure that no data is accidentally duplicated or lost.

5.2.2 The Structure of a Database

To understand a database, think of it as a collection of Tables (like sheets in a workbook). Each table is made of:

1. Fields: These are the columns. Each field holds one specific category of information (e.g., "First Name").
2. Records: These are the rows. A record is a complete set of data about one person or thing (e.g., all the info about Student #101).
3. Primary Key: A unique field that identifies every record. No two records can have the same Primary Key.
Example: Your Student ID number.
4. Foreign Key: This is a Primary Key from one table that appears in a different table to link them together.
5. Composite Key: Sometimes, one field isn't enough to be unique. A Composite Key uses two or more fields together to create a unique identifier.

Memory Aid:
- Fields = Fences (vertical columns).
- Records = Rows (horizontal entries).

5.2.3 Entities and Relationships

In a database, an Entity is just a "thing" we want to store data about (like a Student, a Book, or a Car). These entities have Relationships:

- One-to-One (1:1): Each item in Table A links to exactly one item in Table B.
Example: One Person has one Passport.
- One-to-Many (1:M): One item in Table A links to many items in Table B.
Example: One Teacher has many Students in their class.
- Many-to-Many (M:M): Many items in Table A link to many items in Table B.
Example: Many Students study many different Subjects.

5.2.4 Entity Relationship Diagrams (ERD)

An ERD is a map or a diagram that shows how these tables (entities) connect. It uses boxes for entities and lines to show how they relate. If you see a "crow's foot" symbol (three lines branching out) at the end of a line, it means "Many."

Key Takeaway: Databases use Primary Keys to stay organized and Foreign Keys to connect different tables together.


5.3 Structured Query Language (SQL)

SQL (often pronounced "Sequel") is the standard language used to communicate with databases. If the database is a library, SQL is the librarian you talk to when you want to find, add, or change a book.

5.3.1 Why use SQL?

It allows us to handle huge amounts of data efficiently. Instead of clicking through thousands of rows, we write a short "command" to do the work for us.

5.3.2 Common SQL Commands

1. Finding Data (The SELECT Statement):
We use SELECT to pick the fields, FROM to pick the table, and WHERE to set a condition.
Example: SELECT StudentName FROM Students WHERE Grade = 'A';

2. Creating and Populating Tables:
- CREATE TABLE: Sets up a new table and defines the data types (e.g., INT for numbers, VARCHAR for text).
- INSERT: Adds a new record.
- UPDATE (Amend): Changes existing information.
- DELETE: Removes a record.

3. Linking Tables:
- JOIN: Combines rows from two or more tables based on a related column (usually the Foreign Key).
- UNION: Combines the results of two different SELECT queries into one list.

4. Using Wildcards:
Wildcards are "shortcuts" used when you aren't sure of the exact spelling:
- % (Percent sign): Represents zero or more characters.
Example: WHERE Name LIKE 'J%' finds "Joe", "James", and "Jessica".
- _ (Underscore): Represents exactly one single character.
Example: WHERE Name LIKE 'H_t' finds "Hat" or "Hot".

5. Organizing Results:
- ORDER BY: Sorts the list (Alphabetical or Numerical).
- GROUP BY: Puts identical data into groups.
- COUNT: Returns the number of rows that match your search.

Common Mistake to Avoid:
Don't forget the semicolon (;) at the end of your SQL statement! It tells the computer that your command is finished.

Did you know?
The SELECT command doesn't actually change or delete your data; it just "views" it. It’s like looking through a window at your data without touching it!


Final Summary of Unit 1: Data and Databases

1. Data is raw; Information is meaningful.
2. Structured data is organized into Tables, Fields, and Records.
3. Primary Keys must be unique; Foreign Keys link tables.
4. Relationships (1:1, 1:M, M:M) define how entities connect.
5. SQL is the language we use to SELECT, INSERT, UPDATE, and JOIN data.

Keep practicing those SQL commands—at first, they look like code, but soon they will feel just like writing sentences! You've got this!