Re: Parsing and storing formulas

From: Sylvain Lafontaine ("Sylvain)
Date: 10/30/04


Date: Sat, 30 Oct 2004 19:42:03 -0400

Is the number of users and the number of formulas by user very great or if
there are only a few users, with one formula for each?

In the second case, you could easily store different views/stored
procedures/user defined functions with the same name but different owner;
each user having his own set.

S. L.

"Stefan Rosi" <invalid@invalid.com> wrote in message
news:uc0TP5PvEHA.1300@TK2MSFTNGP14.phx.gbl...
>I was wondering how I can parse a mathematical formula in a storable way.
> For example I have two parameters like X and Y. And the user has to
> specify
> a formula to calculate the result. Like 2(Y+2X). Then this formula has
> to
> be stored for in the database. Each time the user visits a specific page,
> the calculations have to be done according to his own formula.
>
> Till now I have two ideas, the first one is to store the formula in just a
> string and make the variable names identical to their representation
> columns
> in the database. So I can just execute the query against the proper table
> and SQL Server will parse the string and return the result. Anyway this
> method has two drawbacks, first I can't use stored procedure anymore, and
> second the mathematical operations can be very complex, which will be a
> problem because sql server is not a mathematic program.
>
>
>
> The second idea is to represent the formula as a tree. Each inner node
> stands for an operation like multiplication, addition . etc. and the
> leaves
> are either variables or constants: to clarify this idea I will attach a
> diagram with this post. When I want to make the calculations I have just
> to
> cal a function on the root, and it will call the same function on it
> children and so on recursively. The tree will be serialized and saved as
> xml
> in the database.
>
> Anyway this tree will be hard to implement.
>
> So I just wanted to ask if somebody knows a better way to do this task. I
> am
> sure I am not the first person faced with this problem.
>
> How can I parse and store an entered formula? Is there any ready component
> to do it?
>
>
>
> Any answer will be appreciated.
>
> Stefan
>
>
>



Relevant Pages

  • Re: Parsing and storing formulas
    ... >I was wondering how I can parse a mathematical formula in a storable way. ... > be stored for in the database. ... > The second idea is to represent the formula as a tree. ... compiler/interpreter/expression evaluator does. ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: Using XML to serialize a SQL Query
    ... I understand that you need to parse the WHERE clause ... When I retrieve the rule from the database, I need some way to populate ... If I simply store it in the database as "Loan.Amount greater than 500000", ...
    (microsoft.public.dotnet.xml)
  • Re: Text indexing problem.
    ... to make a text indexer, which should parse a text file and store ... the important words and the count of their occurrence in a database. ...
    (comp.programming)
  • Re: Unique identifier in every treenode?
    ... the tree is built. ... It would be up to the client code to impose any sort of unique identifier and store it with the TreeNode. ... Even in a regular database you can use the database itself to specify relationships between records in the database representing nodes, something like XML provides a natural "containment" semantic that would allow the tree structure to be represented without explicit references between nodes, and even a plain text file can be used to reliably store a tree structure as long as you have _some_ way of describing the structure. ...
    (microsoft.public.dotnet.languages.csharp)
  • Read xml file, store data in db. What could be easier?
    ... I am going to receive an xml doc and am going to have to parse the data ... values and store them in the database. ...
    (microsoft.public.sqlserver.xml)