Data Source & Filters
Transcript Summary
Introduction
What's up, databasers! Sam here, and in this video, we are diving into data sources and filters. This video is packed with valuable information, so hold on tight. By the end, you’ll have a clear understanding of how to harness the power of database filters and data sources to effectively display your data.
Overview
We will explore two main concepts:
- Where is the data coming from? – When setting up a data component, we need to know which table to pull data from.
- How do you filter the data? – Even when pulling from a table, you might want to apply filters to display specific records.
Data Source Setup
When you start creating a component, you need to choose a data source. This refers to the table from which you want to display data. Once you select the data source, you cannot change it later without creating a new component.
For example, if you have tables such as users, companies, contacts, etc., and you select the companies table, that table becomes the source of your data. You can add filters after selecting your data source, but the source itself remains fixed.
Filters Setup
Once you've chosen the data source, you can apply filters to refine which records you display. Filters can be modified later, even after the component is set up. This flexibility allows you to change what data is shown based on certain conditions.
Example: Filter by Logged-in User
One common filter is to show only records connected to the logged-in user. For example, if you have a companies table, you can set up a filter to display only companies associated with the current logged-in user. This can be done by creating a filter group and selecting a condition like "is logged-in user."
Exploring Connections and Filters
Now, let’s review an app setup that uses various tables and connections. Here are some of the core tables:
- Users table: Contains users with roles like employees and admins.
- Companies table: Contains company data and includes connections to users (to track which employee or admin added the company).
- Contacts table: Contains contacts associated with companies.
- Jobs table: Tracks jobs related to companies and assigns them to specific users.
In this example, each table is connected logically. For instance, each contact is connected to a company, and each job is connected to both a company and a user.
Building a Page with Company Details
Let’s create a page to display company details. Start by selecting a table component and choosing the companies table as the data source. You can further customize the component by adding filters, such as showing only companies added by the logged-in user.
Example: Filtering by "Added by" Field
You can filter the companies displayed by the added by field, which records who added each company. If the logged-in user matches the person who added the company, the company will be displayed. If not, it won't.
Example: Filtering by Assigned Company
Another option is to filter companies based on the assigned to field, showing only companies assigned to the logged-in user.
Adding and Customizing Filters
Let’s go deeper into filters:
- Basic Filter: You can filter companies by fields like industry or status. For instance, you could display only companies in the Automotive or Conglomerate industries by using a filter group.
- Match All vs. Match Any: When adding multiple conditions to a filter, you can choose between "match all" (AND logic) or "match any" (OR logic). For example, if you filter by both industry and status, you can decide whether both conditions must be met or just one.
Advanced Filter Example: Jobs Table
Let’s create more complex filters using the jobs table. You can filter by company, job status, assigned user, and more. Here’s how you can set up multiple filter groups:
- Filter Group 1: Filter by company (e.g., Tesla).
- Filter Group 2: Add conditions like job status being Open and the job being assigned to the logged-in user.
By adding child filter groups, you can get more granular control. For example, you might filter by jobs where the price is over 100 or status is pending. The child filters allow for deeper customization by allowing conditions within conditions.
Filtering Logic
We begin by setting up a filter with multiple conditions:
- The company must be Tesla.
- The price must be higher than 100.
- Additionally, if the status is open and the user is the logged-in user, the record will also be displayed.
In Tadabase, filters can be combined using "AND" or "OR" logic. For instance:
- The first condition is that the company is Tesla and the price is higher than 100.
- Alternatively, the status can be open and the user is the logged-in user.
- Lastly, if the company is Tesla and the status is pending, the record will also be displayed.
This filter setup allows you to get granular in your data filtering, making sure only the relevant records are shown based on specific conditions.
Use Case Example: Outbound Calls
Consider a scenario where someone is making outbound calls to specific companies. You want to display companies where:
- The price is higher than a certain amount if the status is open.
- If the status is pending, those records are displayed regardless of price because they are more urgent.
By using such filters, only the desired records are shown based on the current status and other conditions.
Example of the Filter in Action
Let’s preview the page:
- The filter is set to show only Tesla records where the price is higher than 100.
- However, if the status is pending, it will still show records, even if the price is below 100.
By adjusting filters, you can precisely control which records are displayed, ensuring the most relevant data appears.
User-Based Filtering
Another useful feature is filtering based on logged-in users. For example:
- You can display records for a specific logged-in user, such as Roger, showing only their assigned jobs.
- If you want to expand this to show all jobs for the logged-in user's role (e.g., the sales team), you can filter by user role. This way, every sales team member can view the team's records.
This role-based filtering ensures that users can see the data relevant to their position, enhancing collaboration.
Sorting Records
When sorting data in Tadabase, you can specify how the records are ordered:
- By default, records are sorted by the record ID.
- You can also sort by other fields like company name or any custom field.
- Adding multiple sort fields is possible but may increase the query load. For instance, you can sort first by company name and then by record ID to ensure records are displayed correctly within each company.
Sorting is a powerful way to organize your data, especially when dealing with large datasets.
Limiting Records
You can limit the number of records displayed:
- For example, you may want to show only the most recent record for a technician. By sorting by ID and limiting the records to one, the technician will always see the latest job they need to complete.
- This helps in scenarios where only the most relevant data needs to be displayed at a time.
Connected and Related Records
In Tadabase, there is a distinction between connected and related records:
- Connected records: These are records linked via a connection field, such as jobs connected to a company.
- Related records: These are records that may not be directly connected but share a relationship through another table. For instance, contact notes related to contacts working at a specific company.
This layered connection allows you to display data at multiple levels, giving you more control over how information is linked and presented.
Example of Related Records
We explored how to display jobs connected to a company and then display contact notes related to contacts within that company. For instance:
- For the company "Meta," you can display all related jobs and contact notes for employees like Mark Zuckerberg or Sheryl Sandberg.
This multi-layered approach ensures that you can pull in all relevant data for a given record, enhancing the user's ability to view connected and related information.
Conclusion
In this video, we covered:
- Filtering data using multiple conditions.
- Sorting and limiting records to display only the most relevant information.
- Connecting and displaying related records in Tadabase.
- The importance of properly sourcing your data when building components.
By mastering these techniques, you can build highly customized and powerful data views that are tailored to your application's needs. Thank you for watching!
We'd love to hear your feedback.