Any number of cats can have the same owner. In this way, an individual cat is associated to the person that owns it. The Cats table has a column, owner_id, that contains a foreign key corresponding to the id column of the Owners table. This Pet's Database has an Owners table and a Cats table. Let's imagine a database that keeps track of pets and their owners. There are two basic types of relationship that we need to concern ourselves with right now: The "has many"/"belongs to" relationship and the "many-to-many" relationship. In relational databases, we can actually categorize the type of relationship that exists between the data that we are storing. Our relational databases have the ability to reflect that related-ness. Employees belong to managers, pets belong to owners, a person has many friends. Real-world objects and environments are relational. Such a database might also have a Managers table that is related to the employees table. We might have an employee database in which an individual row in an Employees table represents one real, individual employee. We use databases to store information that represents real-world entities. This is true of our databases and tables as well as code we write in Ruby, Objective C, you name it. Whether you're developing a web application that helps doctors and hospitals around the country manage patient information or coding a command line game, the code we write is modeled on real situations and things. In other words, we write programs to solve real-world problems or handle real-world situations.
Understand how to build each type of relationship via either the use of foreign keys or the use of a join table.Learn to distinguish between the different types of relationships between data in your database: the "belongs to"/"has many" and "many-to-many" relationships.