Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I'm making a command line tool that allows end users to query a statically-schemed database; however, I want users to be able to specify boolean matchers in their query (effectively things like "get rows where (field1=abcd && field2=efgh) || field3=1234"). I did Googling a solution, but I couldn't find anything suitable for end users--still, this seems like it would be a very common problem so I suspect there is a standard solution.

So:

  1. What (if any) standard query "languages" are there that might be appropriate for end users?
  2. What (if any) de facto standards are there (for example, Unix tools that solve similar problems).
  3. Failing the previous two options, can you suggest a syntax that would be simple, concise, and easy to validate?
share|improve this question
    
1: SQL; 2: ANSI standard SQL; 3: SQL will be validated by whatever RDBMS you submit it to; most likely you'll get a helpful message back saying exactly where the problem was. If the schema naming convention is not end-user friendly define views to present appropriately and grant rights accordingly. –  Michael Green Jul 27 at 11:25
    
Thanks for the comment @MichaelGreen. I naturally considered SQL, but I think I want a read-only subset thereof. If possible, I would like to avoid manually enforcing that rule. I suppose most SQL implementations support read-only configuration, but I would like to return to the user a friendlier message than what the database is likely to yield and translating each low-level database error to a useful high level user error sounds like it would require in-depth knowledge of each sql backend I intend to use. Perhaps this is still the best solution, however... –  weberc2 Jul 27 at 14:08

1 Answer 1

This is called faceted search. There are tools like Solr that can help you do it, but you don't want to use a language unless your users are highly technical (like consumers of a web service API), in which case you just use something SQL-like.

For inspiration on user interfaces, look at search results of companies with huge product lines, like Amazon or Digikey. Basically after you start a search you are presented with a list of parameters by which you can refine your search, allowing you to drill down until you get the products you want. This kind of interface is probably so familiar to you that you may not even have realized you were effectively querying specific fields of a database.

Another example of end user searching based on many fields is bug tracking websites. They generally have a general purpose GUI-based search, and also a SQL-like query language for advanced searches. If your users are technical or semi-technical, that might be a good model to follow.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.