Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

question re how to count items with a join table

Featured Replies

I have a database with 3 tables (to simplify): keywords (keyword_text and keyword_ID), files (filename text and file_ID) and a join table (keyword_ID, file_ID). Suppose I want to have a list view that shows all filenames with their associated count of keywords attached to each file, and conversely another list view with all keywords and their associated count of files attached to each keyword. How would I go about doing that?

Edited by human

There are two ways to show a count of related records:

  1. Define a calculation field in the parent table that uses the Count() function to count the related records; 
  2. Define a summary field in the related table that counts some field that cannot be empty, then place this field on the layout of the parent table.

In the given example, you could use a single summary field defined in the join table for both of your uses. However, this requires you do not have duplicate entries in the join table.

--
P.S. As noted in your other question, you can use an unstored calculation field = Get ( FoundCount ) instead of the summary field.

 

Edited by comment

  • Author

count works, thanks!

However, on a local file this is fast. But when connected to a remote server, trying to sort on that field is extremely slow, because there are over 400K entries in the join table. 

Edited by human

Sorting by an unstored calculation is bound to be slow. Unfortunately, the only cure is denormalization: add a Number field to both tables and make sure they are updated to reflect the current counts - either periodically (e.g. overnight) or on every modification of the join table.

 

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.