I would like to add a table to a doctype which is self-referencing. The specific use case is modifying the Course DocType in Education to create pre-requisite courses so a Student cannot be enrolled unless they have completed all pre-requisite courses.
What are the implications of making a DocType a Child Table (especially one not in an app I am writing). It seems the easiest thing to do is make Course a Child Table, add a Table DocField and set the Option to Course (This sets aside the logic of checking whether previous courses have been satisfied).
Hi there,
A document can’t be both a child table and a non-child table simultaneously. Child tables have special data properties that link them to their parents.
A standard solution to this problem is to create a “linking” doctype. This would likely be as simple as a doctype called “Course Prerequisites” (or whatever), with a single Link field pointing to the course that’s acting as a prereq.
This is a common pattern in Frappe/ERPNext and DB design generally. If you look at “Topics” child table in the Course doctype, there’s already an example of this built in.
I see. In your example “Course Prerequisites” represents the many-to-many linking table. But instead of it linking Table 1 to Table 2, it just links Table 1 to Table 1.
Thanks for the help