M
M
Maxim Y2020-03-19 19:32:09
Database design
Maxim Y, 2020-03-19 19:32:09

How to store combinations of logical operators in a table?

Greetings.

Are there any patterns/best practices for efficient storage of rules consisting of combinations of logical operators?
The task is to dynamically build filters to select records in the table that match the rule. And also be able to edit the rules.
It is preferable to store the rules in a table.

Rule example:
Rule1: (feature1 = 3 AND feature2 > 5) OR feature3 like '*.google.com'

Picture with an example of setting up a rule in the interface:
GUID-A7F33267-8DED-4E56-9635-80EB8B05AC9
I tried to find ideas in Google, but I didn’t get further than truth tables and Karnaugh maps.
Thanks in advance also for the correct wording for Google.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ivan Shumov, 2020-03-19
@inoise

Surprisingly, but the easiest way to store such things is in SQL, KQL (Kusto Query Language), or analogs:
- scarify with a string - parse
when received (with ready-made libraries) and draw an interface
- save as Query when saving
- PROFIT!

X
xmoonlight, 2020-03-20
@xmoonlight

Store the database queries themselves as strings.
Why reinvent the wheel?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question