Chapter 5. Working with Associations

In this chapter, we will cover the following recipes:

  • One-to-one mapping using a foreign key association
  • One-to-one mapping using a common join table
  • One-to-one mapping using a common primary key
  • One-to-many mapping or many-to-one mapping
  • Many-to-many mapping

Introduction

An association represents the relationship between tables. There are two main types of associations: unidirectional and bidirectional. We will take a look at how to use associations with an example.

There are four main well-known types of relationships:

  • One-to-one
  • One-to-many
  • Many-to-one
  • Many-to-many

There are multiple ways to achieve these relationships.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset