How can I implement user-friendly boolean logic in a web form GUI?

Viewed 22420

Currently I have a web application where a user can use dropdown lists to generate SQL SELECT statements like so:

Column Select Dropdown | Operator Dropdown (= != > < <= >=) | Value select dropdown

The user can do this multiple times, and the "filters" are currently all ANDed together.

I want to add the possibility of creating OR statements. I could very easily add ORs in the case where the columns are the same, but what about complex logic statements like

((A OR B OR C) AND (D OR E)) OR (F AND G)?

How can I let users create such statements in a user-friendly way?

EDIT: To specify, user-friendly for a general audience. Currently I work with developers that occasionally hand-code SQL queries for a non-technical client that needs specific information from our database. The goal is that this web app will remove the need for us to hand-code them by giving the client an easy-to-use tool to do it themselves.

EDIT2: Currently the app is not being used by end users. The only data I have as to its use are previous handwritten SQL queries and thus the kind of queries the client asks for. Given that I could simplify it (e.g. limit the users' ability to generate queries to the kinds of queries they tend to ask for), but I want to see if anybody has experience communicating boolean logic simply and completely in GUIs.

Thank you for your time.

9 Answers

Property Filter Form (click to see an image of the form)

I had a similar task, filtering files based on property values. The users are mechanical engineers, so not exactly a "general audience."

In the form, the user creates a set of conditions. Each is listed separately and assigned a letter (A, B, ...).

A default boolean expression (A AND B AND ...) is automatically generated. However, the user can optionally change it as needed, e.g. A AND (B OR C).

It has been in production for over a year, with no major confusion or complaints so far.

Related