I am building an educational application and one of its features is at once student can only be enrolled in 5 courses so for that purpose I need to create a trigger which executes once the student enrolls in the 6th course. Basically the trigger should implement the methodology of removing oldest course so it needs to make sure that it gets the timestamp of each course and removes the edge from the student to course once it finds the oldest enrolled course to ensure that student is enrolled in only 5 courses at any time.
I want the query for that trigger in Apache Age.