Let's say I have:
Calculator #1:
Expression: (True AND False) AND (True OR False)
This expression should be a child of some calculator.
class Calculator(models.Model):
name = ...
class Expression(models.Model):
parent = models.ForeignKey(Calculator)
boolean = AND or OR
sub_exp1 = models.ForeignKey(Expression)
sub_exp2 = models.ForeignKey(Expression)
When I query all the expressions for the Calculator #1, I should get all the subexpressions.
1 AND 2 5
2 AND 3 4
3 leaf node of True
4 lead node of False
5 OR 6 7
6 leaf node of True
7 leaf node of False
From this, I can quickly apply my parse tree.
How would I display the base case/leaf nodes in my model? Also, is there a better way?
Thanks, I would really appreciate any help