Query By Example (QBE)
If we talk about normal queries we fire on the database they should be correct and in a well-defined structure which means they should follow a proper syntax if the syntax or query is wrong definitely we will get an error and due to that our application or calculation definitely going to stop. So to overcome this problem QBE was introduced. QBE stands for Query By Example and it was developed in 1970 by Moshe Zloof at IBM.
It is a graphical query language where we get a user interface and then we fill some required fields to get our proper result.
In SQL we will get an error if the query is not correct but in the case of QBE if the query is wrong either we get a wrong answer or the query will not be going to execute but we will never get any error.
In QBE we don’t write complete queries like SQL or other database languages it comes with some blank so we need to just fill that blanks and we will get our required result.
Consider the example where a table ‘SAC’ is present in the database with Name, Phone_Number, and Branch fields. And we want to get the name of the SAC-Representative name who belongs to the MCA Branch. If we write this query in SQL we have to write it like
SELECT NAME FROM SAC WHERE BRANCH = 'MCA'"
And definitely, we will get our correct result. But in the case of QBE, it may be done as like there is a field present and we just need to fill it with “MCA” and then click on the SEARCH button we will get our required result.
Points about QBE:
- Supported by most of the database programs.
- It is a Graphical Query Language.
- Created in parallel to SQL development.