Build Your Own AI Assistant Part 1 - Creating the Assistant
116820 Views
Is the new Raspberry Pi AI Kit better than Google Coral?
114678 Views
Control Arduino with Python using Firmata / PyFirmata
87081 Views
How to Map with LiDAR - using a Raspberry Pi Zero 2W, RPLidar and Rviz
57314 Views
Creating a Supercomputer with a Raspberry Pi 5 Cluster and Docker Swarm!
53588 Views
Node-Red Automation, MQTT, NodeMCU & MicroPython
52067 Views
LidarBot
Snaszy NAS a 3D printed NAS for Raspberry Pi
Waveshare CM5 boards
The Best Arduino Robot for Beginners
SMARS Lab upgrade with PyCharm
Chicken Nugget Piano
Mini-Rack 3D Design Tutorial
0h 20m
Using the Raspberry Pi Pico's Built-in Temperature Sensor
0h 24m
Getting Started with SQL
0h 32m
Introduction to the Linux Command Line on Raspberry Pi OS
0h 42m
How to install MicroPython
0h 8m
Wall Drawing Robot Tutorial
0h 22m
Learn Linux from the basics to advanced topics.
Learn how to use a Raspberry Pi Pico
Learn MicroPython the best language for MicroControllers
Learn Docker, the leading containerization platform. Docker is used to build, ship, and run applications in a consistent and reliable manner, making it a popular choice for DevOps and cloud-native development.
Learn how to build SMARS robots, starting with the 3D Printing the model, Designing SMARS and Programming SMARS
Learn how to build robots, starting with the basics, then move on to learning Python and MicroPython for microcontrollers, finally learn how to make things with Fusion 360.
Learn Python, the most popular programming language in the world. Python is used in many different areas, including Web Development, Data Science, Machine Learning, Robotics and more.
Learn how to create robots in 3D, using Fusion 360 and FreeCAD. The models can be printed out using a 3d printer and then assembled into a physical robot.
Learn how to create Databases in Python, with SQLite3 and Redis.
KevsRobots Learning Platform
66% Percent Complete
By Kevin McAleer, 6 Minutes
In this lesson, we’ll discuss database normalization, a process that organizes data to reduce redundancy and improve data integrity. You’ll learn about the first three normal forms (1NF, 2NF, and 3NF), which are essential for creating efficient and well-structured databases.
Normalization is a technique used in database design to structure tables and their relationships, minimizing duplicate data and ensuring data integrity. The goal is to create a database that:
Normalization organizes data into a series of tables and establishes relationships based on defined rules, known as normal forms.
A table is in First Normal Form (1NF) if:
Consider the following table that stores a customer’s order and items:
| order_id | customer_name | items | |----------|---------------|----------------| | 1 | Alice | Laptop, Tablet | | 2 | Bob | Smartphone |
This table is not in 1NF because the items column contains multiple values (e.g., “Laptop, Tablet”). To bring it into 1NF, we need to split the items so that each row contains only one item per order:
items
| order_id | customer_name | item | |----------|---------------|------------| | 1 | Alice | Laptop | | 1 | Alice | Tablet | | 2 | Bob | Smartphone |
Now, each column contains only atomic values, meeting the criteria for 1NF.
A table is in Second Normal Form (2NF) if it:
Consider an orders table that includes customer information:
orders
| order_id | customer_id | customer_name | item | |----------|-------------|---------------|------------| | 1 | 101 | Alice | Laptop | | 1 | 101 | Alice | Tablet | | 2 | 102 | Bob | Smartphone |
This table is not in 2NF because customer_name depends only on customer_id, which is part of the primary key (order_id, customer_id). To normalize it, we can separate customer information into its own table.
customer_name
customer_id
order_id, customer_id
orders:
| order_id | customer_id | item | |----------|-------------|------------| | 1 | 101 | Laptop | | 1 | 101 | Tablet | | 2 | 102 | Smartphone |
customers:
| customer_id | customer_name | |-------------|---------------| | 101 | Alice | | 102 | Bob |
Now, the orders table only contains data related to the order, and the customers table holds information specific to customers. This structure meets 2NF requirements.
customers
A table is in Third Normal Form (3NF) if it:
Consider an orders table with additional customer location information:
| order_id | customer_id | customer_name | city | item | |----------|-------------|---------------|----------|------------| | 1 | 101 | Alice | New York | Laptop | | 2 | 102 | Bob | Chicago | Smartphone |
This table is not in 3NF because city depends on customer_id through customer_name, rather than directly on the primary key (order_id). To bring it into 3NF, we should split city into the customers table.
city
order_id
| order_id | customer_id | item | |----------|-------------|------------| | 1 | 101 | Laptop | | 2 | 102 | Smartphone |
| customer_id | customer_name | city | |-------------|---------------|----------| | 101 | Alice | New York | | 102 | Bob | Chicago |
Now, each non-key column depends only on the primary key in each table, meeting 3NF requirements.
Normalization provides several advantages:
Convert to 1NF: Consider the following table and make it 1NF compliant.
Solution:
Convert to 2NF: Consider the following table and make it 2NF compliant.
Solution: Separate customer information into a new table:
Convert to 3NF: Consider the following table and make it 3NF compliant.
Solution: Move city to the customers table:
By following normalization principles, you can create efficient, scalable, and consistent databases. In the next lesson, we’ll go further into Boyce-Codd Normal Form (BCNF) for advanced normalization techniques.
< Previous Next >