Chapter 8. Joins and Multi-Table Operations: Can’t we all just get along?

image with no caption

Welcome to a multi-table world. It’s great to have more than one table in your database, but you’ll need to learn some new tools and techniques to work with them. With multiple tables comes confusion, so you’ll need aliases to keep your tables straight. And joins help you connect your tables, so that you can get at all the data you’ve spread out. Get ready, it’s time to take control of your database again.

Still repeating ourselves, still repeating...

Greg noticed the same values for status, profession, interests, and seeking popping up again and again.

image with no caption

Prepopulate your tables

Wouldn’t it make sense to have a set list of values in some of the tables?

Having many duplicate values will make it easy to prepopulate the status, profession, interests, and seeking tables. Greg wants to load up those four tables with the values already in his old my_contacts table.

First he needs to query his table to find out what’s already in there. But he doesn’t want an enormous list of duplicate values.

image with no caption

Get Head First SQL 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.