You could create a calc field in the Class table as
Count ( Enrollment::primaryKey )
but its usually better – more versatile* – to create a
summary field, type Count of: primaryKey in the Enrollments table
and display that as a related field on the Class table.
You can use the Count() function in a script if you need that number programatically.
*Because you only need to create this field once, then can use in reports or other related tables; the Count() calc field would have to be re-created in each of these related tables.
Since portals show related data (in your case, related students who enrolled in a class), you can use the Count ( ) function to show the count of related records. Inside the function put any related field that always contains data; most people would use the primary key field.
This function will count the number of records in the students table through this relationship.
In the table you want to show the number of students, create an auto enter calculation. Place field on the class table.
Count(Field showing in portal that is not empty) set to allow change.
Count(Student;Student Name) where Student is the name of the portal showing the records.
Auto-enter calculations do not automatically update when the change is to a referenced field in a related record. Adding or removing records from the Student table will thus not update this auto-enter calculation.