Hi all,
I need to store expressions (boolean and arithmetic ones) in the database (if you want to see an example, go to the end of the message).
I don't know if it's better to store the parsed expressions in the database or to store the piece of xml and parse it each time it's required.
- Option 1: Store the parsed expresisons in the database
This implies creating tables in the database, and each time the expression needs to be evaluated (because the operands can have different values during the run of the course) I have to do the respective queries and find the associated sums, ands, if-then-elses, divides, etc. Finally, this info will be only accesed for that purpose.
- Option 2: Store the piece of the xml expression in the database
This implies creating only one table for the expressions. Each time the expression has to be evaluated, the piece of xml is parsed and the database is accesed only to query for the referenced property values.
(FYI, The parsing it's being done using tDOM)
Besides, the xml contains more info, which it's being stored in de database, and the course will be accessed (hopefully some day) each time a student access the unit of learning (which is something like a LORS course)
Could you tell me which one is the better option?, which one is faster?, which one is conceptually the one to go for?
Thanks!
This is the example
......
<imsld:conditions>
<imsld:if>
<imsld:is>
<imsld:property-ref ref="prop-one"/>
<imsld:property-value>true</imsld:property-value>
</imsld:is>
</imsld:if>
<imsld:then>
<imsld:change-property-value>
<imsld:property-ref ref="prop-two"/>
<imsld:property-value>
<imsld:calculate>
<imsld:sum>
<imsld:property-ref ref="prop-three"/>
<imsld:property-value>1</imsld:property-value>
</imsld:sum>
</imsld:calculate>
</imsld:property-value>
</imsld:change-property-value>
</imsld:then>
</imsld:conditions>
......