7

You Broke It; You Fix It: Combining Data Sets

Let us recall from Chapter 3 that normalization of a relational database is the process of arranging the data with maximum precision and minimum duplication. This is largely achieved by establishing relationships between several tables that contain data. The relationships are established through the use of special values, called keys, which are unique to every record in the entire database.

images Formal terminology of the relational theory could be quite confusing. Throughout the book I use friendly terms such as table, row, (record) and column, while the corresponding formal terms would be relation, tuple, and attribute.

This approach is good for maintaining data and minimizing inconsistencies, but it is not exactly user-friendly when it actually comes to using data. A cook would normally have all the ingredients lined up before she embarks on creating a dish, and then combining them according to certain rules. A user of the database must do something similar: Figure out the blocks of the data she wants to access and then fetch all the necessary data from various tables into one temporary structure, or data set. This is a job for the JOIN keyword, briefly touched on in early chapters.

Get Discovering SQL: A Hands-On Guide for Beginners now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.