I have to store logic conditions in database. for instance: (condition1 || condition2) && condition3 ought to be saved in database.

I intend to design a table [ExpressionTree] to handle structure:

Id
condition
combinationId
nextId(FK->[Condition2Combination.Id])
operator (AND, OR, null)

If (condition1 condition2) &lifier&lifier condition3 within the table [ExpressionTree], the records ought to be:

Id  conditionId combinationId nextId  operator
1  condition1   combination1  2       OR
2  condition2   combination1  3       AND
3  condition3   combination1  null    null

However the option would be bad, what’s your suggestion? Thanks!

Unless of course you had been really likely to perform database queries within the expression trees, I'd be inclined to keep the expressions like a text column ... and parse them around the client side as needed.

I do not begin to see the tree structure inside your solution. Particularly, I do not think your nextId column is capable of doing coping with expressions which have parentheses inside them. However I might be missing something.

I would recommend that you simply consider a means of indicating tree structures that's referred to as nested set technique. Within this technique, the "next id" column will get changed by two posts, known as "left id" and "right id" that's able to indicating which subreets are within other subtrees. It is really an over simplified review of what you are likely to find.

Using nested sets, it's not hard to develop a question that discloses the subtree under a node, or even the path from the given node to the main.

Why data inside a database?