4 Replies
I am looking at the University and Student example here.
https://development--typedb-docs.netlify.app/new_home/get_started/schema#_defining_your_schema
In this example, the university entity and student entity are related via the enrollment relation.
In addition, university entity has an attribute called student-count.
Given that student count is basically the number of enrollment relation where university = SomeUniversity, it feels like the student-count attribute is derivable from just counting number of enrollment relation where university=SomeUniversity.
------
Is there something like
where get_student_count is a function which takes unviersity by name, and output a number, based on the relation?
Benefit is that, if the attribute value can be derived from a function, then
- when there's a new enrollment, we dont need to update both student-count + add a new enrollment relation data.
This is basically the 2.x rule system we moved away from. In 3.x you're expected to use the function directly and not have the attribute.
Understood.
For clarity, would it be possible to see the function's signature on the web console's UI?
I suppose it would be nice to be reminded of the custom functions when browsing the web console.
yeah it's a good point, we should have it in studio
let's continue in the other thread
although, i do think there's an interesting future something like what you've written with function-computed attribute values, but it's not on the roadmap/prioritized in the near future @kenho811 🙂