CodingNic

Groups

Organizing Contacts into Groups

Groups 5 min read

Organizing Contacts into Groups

Organizing Contacts into Groups

A contact can belong to more than one group (Work, Family, Book Club), and
a group can have many contacts — a classic many-to-many relationship,
which in a relational database means a third join table sitting
between the two.

This module covers:

  1. Adding groups and contact_groups tables to the schema
  2. A lib/groups.ts data module, and the Groups page (list + create)
  3. The group detail page, reusing getContacts with one more filter
  4. Linking groups to contacts: checkboxes in the form, group chips on the
    detail page, and keeping the join table in sync every time a contact is
    saved

It’s the longest module in the course, but every piece builds directly on
patterns from Modules 2, 3, and 5.