Search This Blog

Monday, July 27, 2009

Rethinking SQL Search in Web Applications

Search is a very common capability that exists in almost all data driven systems. Typically users enter a search criteria and perform a search. Behind the scenes the user's inputs are taken and are converted to a language such as Structured Query Language (SQL) and a query is fired.

While SQL itself is a very expressive syntax, end users are rarely exposed to the entire capabilities of the SQL language. The reason is simple. Traditional web applications cannot expose an entire SQL syntax without complicating the interface. On one hand are fixed parameter based search input screens and on the other hand are these calculator inspired Query Builder tools. With the onset of text indexing a lot of search tools also provide single input text boxes but these cannot be translated to SQL expressions so I will not include them as part of the discourse.

Looking from the users' perspective
In the users mind there are two concepts. Search for and search by. Typically users want to search for, say a second hand car for sale by model, make, manufacture year, etc. These are attributes of the car itself. Alternatively, they may want to search by other criteria related to the car. For example, number of times the car has been sold in the last 2 years. Maybe the location of the seller/ dealer from my house should not exceed X kilometers/miles or the offer price on the car should not exceed Y amount of dollars.

As I can see, the concept of the search is simple. Either I want to search based on the attributes of the entity itself or based on some criteria associated with the entity. At times, I may want to change the object I am searching for. Instead of searching for the second hand car, I may turn my attention to car dealers. I may want to know all car dealers that are selling the car I am interested in. If I have already fired the search for cars in a previous step, I may want to re-use my search results to finding dealers that are selling this car and are rated at a certain level by the industry.

In the next part, I will explore what form this search could take.

No comments: