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
Email with 3 Attachments
Customer with 10 Past Conversations
Report with 100 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
Contains 3 items
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 Items:
What you see:
- Main table shows orders
- The "Items" column shows item count: "3 items"
- Click the arrow to expand and see the sub-table
- Sub-table shows individual items with their own columns
- Each item processes independently
- 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