Skip to content

5.1: Understanding Collections ​

You've built automations that handle individual thingsβ€”one customer message, one lead, one order. But what about when you need to work with multiple related items?

Imagine an order with 5 products, an email with 3 attachments, or a customer with 10 past conversations. These are collectionsβ€”lists of items that belong together.

The challenge: How do you automatically process each item in a list while keeping everything organized?

The solution: Sub-tables! They're Taibles' way of handling collections, and they make complex data relationships surprisingly simple.

πŸ’‘ What You'll Learn

By the end of this section, you'll understand:

  • βœ… What collections are and when you need them
  • βœ… Why processing items individually matters
  • βœ… How sub-tables solve the collections problem
  • βœ… The parent-child relationship pattern

5.1.1: What Is a Collection? ​

A collection is simply a list of multiple items that belong to one thing.

Think of everyday examples:

  • πŸ›’ An order with multiple products
  • πŸ“§ An email with several attachments
  • πŸ’¬ A customer with their conversation history
  • πŸ“Š A report with hundreds of data points

The pattern: ONE parent thing has MANY child items.

Real-World Collection Examples ​

Order with 5 Items

πŸ“¦ Wireless MouseQty: 2
⌨️ Mechanical KeyboardQty: 1
πŸ–₯️ Monitor StandQty: 1
πŸ”Œ USB HubQty: 3
🎧 HeadphonesQty: 1

Email with 3 Attachments

πŸ“„ Invoice_Q4.pdf2.3 MB
πŸ“Š Report.xlsx1.1 MB
πŸ–ΌοΈ Screenshot.png450 KB

Customer with 10 Past Conversations

πŸ’¬ Shipping questionResolved
πŸ’¬ Product inquiryResolved
πŸ’¬ Return requestResolved
+ 7 more conversations...

Report with 100 Data Points

πŸ“ˆ Jan 2024$12,450
πŸ“ˆ Feb 2024$15,230
πŸ“ˆ Mar 2024$18,900
+ 97 more data points...

Each of these scenarios has the same challenge: How do you work with EACH item while keeping track of what they belong to?

πŸ’‘ πŸ’‘ Think of It Like This

A shopping cart is a perfect analogy for collections:

  • The cart itself is the parent (one order)
  • The items in the cart are the children (multiple products)
  • You need to process each item separately (check stock, calculate price)
  • But you also need the total for the whole cart!

5.1.2: Why Process Items Individually? ​

Sometimes you need to DO something with EACH item in a collection.

Here are common scenarios:

Scenario 1: Order Processing ​

You receive an order with 5 products. For each product, you need to:

  • Check if it's in stock
  • Calculate the line total (quantity Γ— price)
  • Update inventory levels
  • Then calculate the order total from all line totals

Scenario 2: Email Attachments ​

You receive an email with 3 attachments. For each attachment, you need to:

  • Scan for viruses
  • Extract text content
  • Categorize the document type
  • Then summarize all attachments in one response

Scenario 3: Customer History ​

A customer contacts support. You want to check their past 10 conversations and:

  • Extract common issues from each conversation
  • Calculate satisfaction scores for each
  • Identify patterns across all conversations
  • Then provide a summary to the support agent

The pattern: Process each item β†’ Gather results β†’ Use combined information

Why This Matters ​

Processing Items One by One

Order #1234

Contains 3 items

Item 1: Laptop
Item 2: Mouse
Item 3: Keyboard

Process EACH item separately

Item 1: Laptop

β†’ Check stock: βœ“ In stock

β†’ Calculate price: $1,299.00

Item 2: Mouse

β†’ Check stock: βœ“ In stock

β†’ Calculate price: $29.99

Item 3: Keyboard

β†’ Check stock: βœ“ In stock

β†’ Calculate price: $79.99

All items processed! βœ“

Total: $1,408.98

Without processing items individually:

  • ❌ Can't check stock for each product
  • ❌ Can't scan each attachment separately
  • ❌ Can't analyze each conversation
  • ❌ Can't calculate accurate totals
  • ❌ Hard to handle items with different requirements

With individual item processing:

  • βœ… Each item gets the right treatment
  • βœ… Results roll up to parent automatically
  • βœ… Easy to track progress
  • βœ… Simple to debug issues
  • βœ… Flexible for complex logic

πŸ’‘ 🎯 The Power of Collections

By processing items individually, you can handle complex scenarios that would be nearly impossible otherwise. An order with 100 items? No problemβ€”each one gets processed automatically!


5.1.3: The Solution: Sub-Tables ​

A sub-table is like a mini-table that lives inside a cell of your main table.

Here's the magic:

  • The parent table has your main entities (orders, customers, emails)
  • The sub-table has the related items (order items, conversations, attachments)
  • Each child row knows which parent row it belongs to
  • You can add columns and automations to both tables!

Visual: How Sub-Tables Look ​

Sub-Tables: A Mini-Table Inside a Cell

Order ID
Customer
Items
Total
#1234
Sarah Chen
3 items
$1,408.98

Order Items:

Product
Quantity
Price
Line Total
Laptop
1
$1,299.00
$1,299.00
Mouse
1
$29.99
$29.99
Keyboard
1
$79.99
$79.99
#1235
John Smith
2 items
$599.98
#1236
Emma Johnson
5 items
$2,145.00
Click the arrow to expand/collapse items for each order

What you see:

  1. Main table shows orders
  2. The "Items" column shows item count: "3 items"
  3. Click the arrow to expand and see the sub-table
  4. Sub-table shows individual items with their own columns
  5. Each item processes independently
  6. Results combine back to the parent

The Parent-Child Relationship ​

Parent β†’ Children Relationship

PARENT ROW

Order #1234

Customer: Sarah Chen

CHILD ROWS (in sub-table)

ITEM 1

Laptop

Qty: 1

$1,299.00

ITEM 2

Mouse

Qty: 1

$29.99

ITEM 3

Keyboard

Qty: 1

$79.99

Each child row belongs to one parent row

Key concepts:

  • One parent can have many children
  • Each child belongs to exactly one parent
  • Parent and children can both have columns and automations
  • Data flows both directions (parent to child, child to parent)

5.1.4: How Sub-Tables Work ​

Think of sub-tables as two connected tables:

1. Parent Table (Main Table)

  • Regular table like you've been using
  • Has a special "sub-table column" that shows item count
  • Parent-level columns work with parent-level data
  • Example: Order total, customer name, order date

2. Child Table (Sub-Table)

  • A separate table, but linked to parent rows
  • Each row automatically connected to a parent row
  • Child-level columns work with individual items
  • Example: Product name, quantity, price, line total

The Connection:

  • Sub-table column in parent links to child table
  • Each child row has a hidden "parent" reference
  • You can access parent data from child rows
  • You can aggregate child data up to parent

πŸ’‘ πŸ’‘ Like Folders and Files

Think of it like your computer's file system:

  • Folder = Parent row (one order)
  • Files inside = Child rows (order items)
  • The folder "contains" the files
  • Each file "knows" which folder it's in
  • You can see folder properties AND file properties

5.1.5: When Do You Need Sub-Tables? ​

Use sub-tables whenever you have a one-to-many relationship:

βœ… Perfect for Sub-Tables ​

E-commerce:

  • Orders β†’ Line items
  • Carts β†’ Products
  • Invoices β†’ Invoice lines

Communication:

  • Emails β†’ Attachments
  • Conversations β†’ Messages
  • Campaigns β†’ Recipients

Projects:

  • Projects β†’ Tasks
  • Customers β†’ Support tickets
  • Reports β†’ Data points

Data Processing:

  • Batches β†’ Records
  • Forms β†’ Form fields
  • Surveys β†’ Survey responses

❌ When NOT to Use Sub-Tables ​

You probably DON'T need sub-tables if:

  • Each row only has one of something (one customer name, one email address)
  • The data is a simple value, not a list
  • Items don't need individual processing
  • There's no parent-child relationship

πŸ’‘ ⚠️ Keep It Simple

Don't use sub-tables just because you can. Only use them when you genuinely need to process multiple related items. For simple data, regular columns work great!


5.1.6: What's Coming Next ​

Now that you understand what collections are and why sub-tables are the solution, you're ready to build your first sub-table!

In the next section (5.2: Creating Sub-Tables), you'll:

  • πŸ› οΈ Create your first sub-table step-by-step
  • 🎯 Process order items automatically
  • πŸ“Š Calculate totals from child data
  • ✨ See the power of sub-tables in action

Get excited! Sub-tables might seem complex at first, but once you see them in action, you'll wonder how you ever lived without them.

πŸ’‘ πŸŽ‰ You're Ready!

You now understand:

  • βœ… Collections are lists of related items
  • βœ… Processing items individually is often necessary
  • βœ… Sub-tables are mini-tables inside cells
  • βœ… Parent-child relationships connect the data
  • βœ… When to use (and when NOT to use) sub-tables

Let's build one! β†’


What You've Learned ​

Congratulations! You now understand the concept of collections and why they matter:

πŸ“ Collections are lists of multiple items that belong together

πŸ”„ Processing items individually lets you handle each item with its own logic

πŸ“Š Sub-tables are the solutionβ€”mini-tables inside cells

πŸ‘¨β€πŸ‘§β€πŸ‘¦ Parent-child relationships connect main entities to their related items

🎯 Know when to use sub-tables (one-to-many relationships)

Next up: Let's actually build a sub-table and see the magic happen! You'll create an order processing system that handles multiple items automatically.


Previous: 4.3 Conditional ActionsNext: 5.2 Creating Sub-Tables

Built with VitePress