What is HubDB?
HubDB is a database tool inside of the HubSpot portal that allows users to create a table that contains rows and columns, that can be used for utilized in various ways throughout a site.
Each new row is assigned its own unique ID so that specific rows can be targeted by code if the developer needs it.
Each Column in the row can be assigned a different type of content, such as basic text, a rich text field, an image field, a video field, etc. These can then be displayed within future modules when they are connected to the HubDB table. There is a section for the column label, name, and description to help anyone who may go into the table in the future better understand what each section is responsible for.
HubDB tables may also have content imported into them from existing CSV files on the user’s end. Upon uploading the CSV file, HubSpot will ask you to map the existing CSV column content to the columns inside of the HubDB table. This can be used to upload bulk content all at once if it already exists, instead of having to create each row, one-by-one.
Conversely, a HuDB table’s data can also be exported to a CSV, XLS, or XLSX file that can then be saved to the user's desktop.
Figure 1.
Mapping a CSV file’s information:
—————————————————
Integrating a HubDB table with a custom module:
Once the table has the desired content, you will be able to publish it. Once the table is published, it will be able to be accessed so that the content is able to be shown to viewers.
Once that is done, you are able to connect the table to a module by adding a hub declaration within the custom module code.
The HubL function hubdb_table_rows() can be used in a for loop to display all of the rows of the table specified. The function will take 2 parameters, one for the tableID or name, and one for a filter Query, which can be used to limit the amount of content displayed or to display specific content to the viewer.
Using this, the table can be used to display content in a variety of ways, such as a product catalog, a collection of testimonials, or a listing of open job positions. There are many examples online of interesting setups people have created using their own HubDB tables to display content to users in unique and interesting ways.
Figure 2.
Example of a customer testimonial module using a HubDB table with an '&orderBy=random()' parameter:
Figure 3.
And when the page is refreshed:
This is just a small example of some of the interesting ways content can be displayed and filtered for specific layouts to the end users.
Other uses for HubDB:
HubDB can also be used to set up dynamic webpages, which are pages that are created based on content directly from the table. It will create a listing page that has all of the data from the table itself, and then also create individual pages for each separate row, listing all the information from that row’s columns. A good example use case for this would be a team member page. There would be one overview page setup, with each individual team member having their own page with their specific information from the table row relevant to them when you click their link on the overview page.
The explanation on how exactly to set this up is somewhat in-depth, but HubSpot has a step-by-step article here describing how to set one up using your own HubDB table: https://developers.hubspot.com/beta-docs/guides/cms/content/data-driven-content/dynamic-pages/hubdb
——————————————————
One thing to note about using HubDB is that there are some limitations on the amount of content per account which are as follows:
• Account limits:
- 1,000 HubDB tables per account.
- 1 million HubDB rows per account.
- Table limits:
- 250 columns per table.
- 10,000 rows per HubDB table.
- 700 characters per table name.
- 700 characters per table label.
- Column limits:
- 65,000 characters per rich text column.
- 10,000 characters in each text column.
- 700 characters per column name.
- 700 characters per label.
- 300 characters per column description.
- 700 characters per selectable option within a column.
- Page limits:
- 10 calls to the hubdb_table_rows HubL function per CMS page.
- 10 dynamic pages using the same HubDB table.
- HubDB's with dynamic pages turned on must have lowercase paths so that URLs to these pages can be case-insensitive.