Database Count on Column?

I’m working on a Covid-tracking iOS app for my college campus. I have a Google Map with pins at all the residence hall locations. I have two database tables ResidenceHalls = {hallName, latitude, longitude, cases} and Reports = {campusAffiliation, hallName, phoneNumber, userID}. I am wondering if it is possible to have the cases column in ResidenceHalls be equal to the sum of hallNames in Reports?

Hi Seth,

It would be possible to add a dynamic property to be returned when you request data from the ResidenceHalls table. Here’s the API for adding dynamic properties:

What you need to do is add a property that looks like this (the whole value is a string you pass as one dynamic property name):
count(cases.objectId) as totalCases

Hope this helps.

Hope this helps

Hi Mark,

That kind of makes sense! Do I also need to add a Data Relation between the two tables?

Yes, the tables must be related. In my response I made an assumption that the cases column IS the relation column to the Reports table.