Courseiva
DA0-002Chapter 4 of 17Objective 2.1

Relational Databases, Normalization, and SQL Basics

Relational databases, normalisation, and SQL. These are the trio that transforms a chaotic pile of data into a powerful, searchable, and trustworthy system. For the DA0-002, you must understand that businesses cannot make decisions on bad data, and these three concepts are the tools used to ensure data is accurate, consistent, and easy to retrieve.

12 min read
Intermediate
Updated Jul 23, 2026
Reviewed by Johnson Ajibi· Senior Network & Security Engineer · MSc IT Security

A simple way to picture Relational Databases, Normalization, and SQL Basics

The Personal Cookbook Analogy

3,000 recipes. That is how many your grandmother's old, stained cookbook contains. It is a mess. You want to find the recipe for 'Sunday Roast Chicken', but you have to flip through pages about cakes, salads, and pasta sauces to find it. Worse, the recipe for the roast chicken lists '4 cloves of garlic', but the shopping list at the back says '2 bulbs'. The ingredient for 'chicken stock' appears in 200 different recipes, each time written out in full, taking up pages of space. This is the *problem* relational databases solve.

Your cookbook is a *spreadsheet* or a *flat-file*. It is a single, big, messy list. A relational database is like a set of neat, small, connected index cards. You would have one card for 'Recipes' (listing only the recipe name and the cooking time). Another card for 'Ingredients' (listing every ingredient you own, like 'garlic', 'chicken', 'butter', each only once). A third card, the 'Recipe-Ingredient' card, would just connect the two. It would say 'Recipe #10 (Roast Chicken) needs Ingredient #8 (Garlic)'. It does not repeat the full ingredient name; it just uses a tiny reference number. This saves space, prevents confusion (one official 'garlic', not 'garlic clove' and 'garlic bulb'), and makes it incredibly fast to find all recipes that use garlic. The relational database is your tidy, organised system of index cards, and the SQL query is the language you use to ask the cards a specific question, like 'Show me all recipes that use garlic and take less than 1 hour to cook.'

How It Actually Works

Let us start with the central idea: a database is simply a structured collection of data. Think of it as a digital filing cabinet. Before computers, you might have had a filing cabinet with folders for each customer. When a customer placed an order, you would write the order details on a piece of paper and file it in their folder. This works for a small business, but it breaks down when you have thousands of customers and millions of orders. You cannot quickly find all orders placed yesterday, or all customers who live in London, without spending hours manually flipping through papers.

A relational database solves this by storing data in *tables*. A table is like a spreadsheet with rows and columns. Each table holds information about one specific type of thing. For example, you would have one table called Customers with columns like CustomerID, Name, and Address. You would have another table called Orders with columns like OrderID, OrderDate, and CustomerID. The magic is in the CustomerID column. This column in the Orders table refers back to the Customers table. This creates a relationship between the two tables. An order belongs to a specific customer. This is the 'relational' part of 'relational database'. It stops you from having to write the customer's full name and address on every single order, which is messy and prone to errors.

Normalisation is the process of designing your tables to minimise this repetition and avoid data anomalies. Think of it as the rulebook for tidying your database. The rules are called 'normal forms'. The first rule, First Normal Form (1NF), says that every column in a table should contain only one value, and every row should be unique. For example, you should not have a column called PhoneNumbers that contains '020 7946 0958, 07700 900 002'. Instead, you should have a separate table for phone numbers, or a second column called PhoneNumber2. The second rule, Second Normal Form (2NF), says you must remove data that is only dependent on part of a unique identifier (the primary key). The third rule, Third Normal Form (3NF), says you should remove data that is not directly dependent on the primary key. For instance, in an Orders table, the customer's address should not be stored because the address depends on the customer, not on the order itself. You would store the address in the Customers table and just reference the CustomerID in the Orders table. This is the core of normalisation: decomposing data to reduce redundancy and improve integrity.

SQL (Structured Query Language) is the language you use to talk to the relational database. It is a simple, English-like language used to create, read, update, and delete data (often called CRUD operations). The most common command is SELECT, which is used to retrieve data. A basic SQL query looks like this: SELECT * FROM Customers; This says, 'Show me everything from the Customers table.' A more useful query would be: SELECT Name, Address FROM Customers WHERE City = 'London'; This says, 'Show me the Name and Address of all customers who live in London.'

You can also combine data from multiple tables using a JOIN. For example: SELECT Customers.Name, Orders.OrderDate FROM Customers INNER JOIN Orders ON Customers.CustomerID = Orders.CustomerID WHERE Orders.OrderDate = '2024-01-01'; This query retrieves the names of customers who placed orders on January 1st, 2024, by joining the Customers and Orders tables on the common CustomerID field. Understanding these basic operations - SELECT, FROM, WHERE, JOIN, INSERT, UPDATE, DELETE - is the foundation of working with any relational database.

Why does this matter for the DA0-002 exam? The exam expects you to understand the purpose of normalisation and how it improves data quality. You must be able to identify which normal form a table is in (usually 1NF, 2NF, or 3NF). You will also be asked to read simple SQL queries and predict the output, or to identify the correct SQL syntax for a given task. The exam will not ask you to write complex queries from scratch, but it will test your ability to recognise a correct query and understand the logic behind it. The most common mistakes come from confusing the different normal forms or misunderstanding how a JOIN works. Once you grasp the core concepts - tables, relationships, normalisation rules, and basic SQL commands - you will be well prepared for the exam.

A simple entity-relationship diagram showing how the Customer, Order, and Product tables are linked via primary and foreign keys.

Walk-Through

1

Identify Entities and Attributes

You start by defining what 'things' you are storing data about (like Customers, Orders, Products). Each 'thing' is an entity that will become a table. Then you list the attributes (columns) for each entity, such as CustomerName, OrderDate, ProductPrice.

2

Define Primary Keys

For each table, choose a primary key that uniquely identifies each row. This is often a single column like CustomerID, but it can be a combination of columns (composite key) if needed. Primary keys cannot be NULL and must be unique.

3

Establish Relationships and Foreign Keys

Decide how tables relate to each other (one-to-many, many-to-many). Add a foreign key column in the 'many' side table that references the primary key of the 'one' side table. For example, add CustomerID to the Orders table to link each order to its customer.

4

Apply Normalisation Rules (1NF, 2NF, 3NF)

Check your tables against the normal forms. Ensure no repeating groups (1NF). Remove partial dependencies by splitting tables if needed (2NF). Remove transitive dependencies by splitting out related data (3NF). This step reduces redundancy and improves data integrity.

5

Write and Execute SQL Queries

Once the database structure is designed, you use SQL to populate it (INSERT), retrieve data (SELECT), update records (UPDATE), and delete data (DELETE). You write queries to answer specific questions, using JOINs to combine tables and WHERE/HAVING to filter results.

What This Looks Like on the Job

As an IT professional, you will rarely build these databases from scratch. More commonly, you will find yourself querying an existing database to answer a business question. For example, imagine you work at a mid-sized retail company. The marketing team asks you, 'We want to send a promotion to customers who have not made a purchase in the last 90 days. Can you give us their names and email addresses?'

Here is what you would do, step by step: 1. Identify the relevant tables. You know the database has a Customers table and an Orders table. The Customers table has columns like CustomerID, FirstName, LastName, Email. The Orders table has columns like OrderID, CustomerID, OrderDate, TotalAmount. 2. Check for data anomalies. Before you write the query, you need to ensure the data is reliable. Are there customers with missing email addresses? Are there duplicate customer records? This is where your understanding of normalisation helps you spot potential problems. A well-normalised database minimises these issues. 3. Write the SQL query. You write a query to find customers who exist, but whose last order date is more than 90 days ago. You might use the MAX function on the OrderDate column. The query could look like:

SELECT Customers.FirstName, Customers.LastName, Customers.Email
    FROM Customers
    LEFT JOIN Orders ON Customers.CustomerID = Orders.CustomerID
    GROUP BY Customers.CustomerID
    HAVING MAX(Orders.OrderDate) <= NOW() - INTERVAL 90 DAY
       OR MAX(Orders.OrderDate) IS NULL;

(The LEFT JOIN and IS NULL part catches customers who have never placed an order.) 4. Interpret the results. You run the query and get a list of 500 names and emails. You check a few manually to verify the logic is correct. You then export this list to a CSV file for the marketing team. 5. Handle errors. You may run into issues. For instance, if the OrderDate column is stored as a text string instead of a date type, your date calculation will fail. You will need to fix the data type or use a conversion function. This is a common real-world headache.

Another common task is data cleaning. You might notice that the State column in the Customers table contains values like 'NY', 'New York', and 'N.Y'. You would write an UPDATE query to standardise these. For example: UPDATE Customers SET State = 'NY' WHERE State IN ('New York', 'N.Y.', 'State of New York'); Without normalisation, this sort of messiness would be much more widespread and harder to fix.

Finally, you might be asked to generate basic reports. The sales team might want a monthly sales report. You would write a SELECT query that sums the TotalAmount from the Orders table, groups by month, and joins with the Customers table to show which customers are buying the most. These are the day-to-day tasks of an IT professional working with data – turning business questions into SQL queries and ensuring the underlying data is of high quality.

How DA0-002 Actually Tests This

The DA0-002 exam has a specific, predictable pattern for testing this objective (2.1). Do not study everything about databases; study exactly what the exam asks. The exam is multiple-choice, and the questions fall into three main categories:

- Recognising Normal Forms. The exam loves to present a table that is in First Normal Form (1NF) and ask you how to put it into Second Normal Form (2NF) or Third Normal Form (3NF). A classic trap is a table that looks normal but contains repeating groups (violating 1NF) or transitive dependencies (violating 3NF). For example, a table with columns OrderID, CustomerID, CustomerName, CustomerAddress is not in 3NF because CustomerName and CustomerAddress depend on CustomerID, not on OrderID. The correct answer will require you to split the table into a separate Customers table. - Key definitions to memorise: - 1NF: Each column has atomic (single) values; no repeating groups; each row is unique. - 2NF: It is in 1NF, AND every non-key column is fully functionally dependent on the entire primary key (no partial dependency). - 3NF: It is in 2NF, AND no non-key column is transitively dependent on the primary key (no non-key column depends on another non-key column).

Interpreting SQL SELECT Statements. You will be given a short SQL query and asked to predict the output. The most common trap is confusing JOIN types. They will ask you to describe the result of an INNER JOIN versus a LEFT JOIN versus a RIGHT JOIN. For example, a question might show a LEFT JOIN between Customers and Orders and ask how many rows the result will have. The correct answer is that the result includes all rows from Customers, even those with no matching orders, unlike an INNER JOIN which only shows customers who have placed an order.

Another common trap: the WHERE clause versus the HAVING clause. WHERE filters rows before grouping (used with GROUP BY), while HAVING filters groups after grouping. The exam will give you a query with both and ask what the result is.

They also test the difference between COUNT(*), COUNT(column_name), and COUNT(DISTINCT column_name). COUNT(*) counts all rows, COUNT(column_name) counts non-NULL values, and COUNT(DISTINCT column_name) counts unique non-NULL values.

Basic Database Concepts. The exam asks about the purpose of primary keys and foreign keys. A primary key is a column (or set of columns) that uniquely identifies each row in a table (e.g., CustomerID). A foreign key is a column in one table that references the primary key of another table (e.g., CustomerID in the Orders table). The trap is confusing the two, or forgetting that a foreign key can be NULL, but a primary key cannot.

Exam traps to watch out for: - Questions that present a table with sample data and ask if it violates a normal form. Look carefully for duplicate data in a column that should be unique, or for multi-valued entries in a single cell. - Questions about DELETE versus DROP versus TRUNCATE. DELETE removes rows but keeps the table structure; DROP removes the entire table; TRUNCATE removes all rows but keeps the table structure (faster than DELETE). - Questions that use aliases (AS) in a SELECT statement and ask you which column name appears in the output.

The correct answer pattern: The correct answer is almost always the one that most strictly adheres to the normalisation rules or that reflects the most standard SQL syntax. If you are stuck, choose the answer that reduces redundancy and improves data integrity.

Key Takeaways

A relational database stores data in tables that are connected through relationships defined by primary and foreign keys.

Normalisation is the process of organising data to minimise redundancy and dependency, primarily divided into 1NF, 2NF, and 3NF.

First Normal Form (1NF) requires that each column contains atomic values and each row is unique.

Second Normal Form (2NF) requires no partial dependencies on a composite primary key.

Third Normal Form (3NF) requires no transitive dependencies (non-key columns cannot depend on other non-key columns).

SQL is a standard language for querying and manipulating data in relational databases, with SELECT being the most commonly used command.

A JOIN clause combines rows from two or more tables based on a related column, with INNER JOIN returning only matching rows and LEFT JOIN returning all rows from the left table.

A primary key uniquely identifies each row in a table and cannot contain NULL values, while a foreign key references a primary key in another table and can be NULL.

The WHERE clause filters rows before grouping, while the HAVING clause filters groups after the GROUP BY clause has been applied.

Data integrity is ensured by normalisation and the use of constraints like primary keys, foreign keys, and NOT NULL constraints.

Easy to Mix Up

These come up on the exam all the time. Here's how to tell them apart.

Primary Key

Uniquely identifies each row in its own table

Cannot contain NULL values

Only one per table (can be composite)

Prevents duplicate rows

Foreign Key

References the primary key of another table

Can contain NULL values

Multiple foreign keys can exist in one table

Used to establish relationships between tables

INNER JOIN

Returns only matching rows from both tables

Excludes rows with no match on either side

Can reduce the number of rows in the result set

LEFT JOIN

Returns all rows from the left table

Includes NULL values for right table columns when no match exists

The number of rows is at least as many as the left table

First Normal Form (1NF)

Requires atomic (single) values per column

No repeating groups or arrays

Each row must be unique (has a primary key)

Third Normal Form (3NF)

Must already be in 2NF

No transitive dependencies (non-key column depends only on primary key)

Aims to remove data that is not directly related to the primary key

WHERE Clause

Filters rows before aggregation or grouping

Cannot be used with aggregate functions like COUNT or SUM

Can be used without GROUP BY

HAVING Clause

Filters groups after aggregation and GROUP BY

Used with aggregate functions

Must be used with GROUP BY clause

DELETE Statement

Removes specific rows from a table

Can include a WHERE clause to target rows

Table structure and definition remain intact

DROP Statement

Removes the entire table and its structure from the database

Cannot include a WHERE clause

Cannot be rolled back in most databases once executed

Watch Out for These

Mistake

Normalisation always makes a database faster.

Correct

Normalisation often improves data integrity, but it can slow down queries because data is split across multiple tables requiring JOINs. Denormalisation (adding redundant data) is sometimes used to improve read performance.

Beginners hear 'normalisation is good' and assume it always improves performance, not understanding that it is a trade-off between speed and accuracy.

Mistake

A primary key must always be a single column.

Correct

A primary key can be a composite key, which is made up of two or more columns (e.g., OrderID + ProductID in a order items table). This is called a composite primary key.

Most examples show a single column ID as the primary key, leading beginners to assume it is the only way.

Mistake

A foreign key must have the same name as the primary key it references.

Correct

A foreign key can have any name, as long as it references the primary key of another table. For example, the primary key may be 'CustomerID', and the foreign key in the Orders table could be named 'CustID'.

In many teaching examples, the names are kept the same for clarity, which causes confusion when real-world databases use different names.

Mistake

SQL is the same across all database systems (Oracle, MySQL, SQL Server).

Correct

While SQL is standardised, each database system has its own dialect and proprietary functions (e.g., `SYSDATE` in Oracle versus `NOW()` in MySQL). The core concepts (SELECT, JOIN) are the same, but specific syntax differs.

Beginners often learn SQL in one environment and assume it works the same everywhere, leading to errors in a different system.

Mistake

A table in 1NF is automatically in 2NF.

Correct

Being in 1NF is a prerequisite for 2NF, but a table can be in 1NF and still violate 2NF if it has partial dependencies (non-key columns depending on part of a composite primary key).

The stepwise nature of normal forms is often misunderstood; people think they automatically progress through the levels.

Mistake

The WHERE clause can be used with aggregate functions like COUNT or SUM.

Correct

The WHERE clause filters rows before aggregation. To filter after aggregation, you must use the HAVING clause. For example, `SELECT Country, COUNT(*) FROM Customers GROUP BY Country HAVING COUNT(*) > 10;`

Beginners try to write `WHERE COUNT(*) > 10` which is syntactically incorrect, and they do not understand the difference in execution order.

Do You Actually Know This?

Reveal each answer, then mark whether you got it right. Score 60%+ to unlock the next chapter.

Frequently Asked Questions

What is the difference between a primary key and a foreign key?

A primary key uniquely identifies each record in its own table and cannot be NULL. A foreign key is a column in another table that references a primary key, linking the two tables together.

Is normalisation always required?

Normalisation is best practise for data integrity, but it is not always required. Sometimes databases are deliberately denormalised to improve query performance by reducing the number of JOINs, at the cost of potential data duplication.

What is the difference between WHERE and HAVING in SQL?

WHERE filters individual rows before any grouping occurs. HAVING filters groups after the GROUP BY clause has been applied. You use HAVING with aggregate functions like COUNT or SUM.

Can a table have more than one primary key?

No, a table can have only one primary key. However, that primary key can be a composite key, which consists of multiple columns that together uniquely identify a row.

What does an INNER JOIN return?

An INNER JOIN returns only the rows where there is a match in both tables. If a row in the first table has no matching row in the second table, it will not appear in the result.

What is a transitive dependency in normalisation?

A transitive dependency occurs when a non-key column depends on another non-key column, rather than directly on the primary key. For example, in a table with columns StudentID, CourseID, InstructorName, the InstructorName depends on the CourseID, not on the composite key (StudentID, CourseID), so it is a transitive dependency that violates 3NF.

Terms Worth Knowing

Keep going

You've finished Relational Databases, Normalization, and SQL Basics. Continue through the DA0-002 study guide to build a complete picture of the exam.

Done with this chapter?