Query by Example

from Wikipedia, the free encyclopedia

Query By Example ( QBE ; Engl. , "Query by means of examples") is a relational database query language , by Moshe M. Zloof in IBM parallel to system R has been developed. It is essentially based on the domain calculus . Here, the query (is the query ) is not as in SQL is represented by a text, but by a table frame, which with special Editor can be edited. This graphical query language is aimed specifically at casual users who have little knowledge of SQL and other complex queries.

use

QBE-like interfaces can still be found today as graphical front ends for database systems.

The QBE interface can be found, for example, as one of several query functions implemented in the DOS database programs dBASE -IV and -V, which were widely used from 1988-1995.

QBE is relationally complete , but some queries require a series of QBE queries, so it is not strictly relationally complete .

When searching in search engines , Query by Example means the search for documents that have a minimum match to a selected example document.

Principles

The system first provides a table structure (also: skeleton) that the user can fill with example elements , comparison operations and commands . There is a special table for more complex conditions, the condition box . Aggregate functions can also be used. Lines can also be negated as a whole.

Example elements begin with "_" and are used to link tables (join) and to specify conditions in the condition box. Comparison operations are specified in a cell, for example the entry “> 7” compares the attribute accordingly. The commands are P., I. and D. and stand for print, insert and delete. I. and D. are always specified in the first column, P. can be in the first column to output the entire line, or in the case of one or more attributes, to output only these attributes - a negated line may not contain P. .

Examples

Let the following relations exist in the system:

CUSTOMER (kdnr, kname, address, place)
ASSIGNMENT (order no., customer no., goods no., quantity)
WOULD (product no., wname, wpreis)

In QBE, queries are then made by filling the table structures.

Places where there are customers
CUSTOMER kdnr kname address place
P.
All customers from Bremen
CUSTOMER kdnr kname address place
P. = 'Bremen'

These examples show how the projection (hiding columns) and the selection (hiding lines) are implemented. Two queries that use joins and use example elements:

Customers with order
CUSTOMER kdnr kname address place
P. _kdnr
ASSIGNMENT order number kdnr goods no amount
_kdnr

The next example shows the use of negated lines:

Goods without an order
WOULD goods no wname wpreis
P. _good no
ASSIGNMENT order number kdnr goods no amount
¬ _good no

The cross product of two relations would be formed as follows:

Entries in table frameworks
WOULD goods no wname wpreis
_good no _wname _wprice
ASSIGNMENT order number kdnr goods no amount
_order number _kdnr _warennr2 _amount
New table framework W × A
W × A goods no wname wpreis order number kdnr goods no amount
P. _good no _wname _wprice _order number _kdnr _warennr2 _amount

For the implementation of the set operations of relational algebra several statements are necessary. If one had two relations with the CUSTOMER scheme, CUSTOMER and SCAM, one could obtain all possible CLIENTS by combining the two relations. This can only be done with two operations, not a single one:

CUSTOMER kdnr kname address place
_kdnr _kname _address _place
New table structure
CLIENT kdnr kname address place
I. _kdnr _kname _address _place

First the values ​​of the CUSTOMER relation are inserted into a new relation. Then, in a second operation, the CHEATERS come along:

CHEATERS kdnr kname address place
_kdnr _kname _address _place
CLIENT kdnr kname address place
I. _kdnr _kname _address _place

The new relation now contains CUSTOMER ∪ CHEATER.

Web links

  • Ramakrishnan, Raghu; Gehrke, Johannes: Query by Example. (PDF; 140 kB) In: Database Management Systems (3rd ed.). www.cs.wisc.edu, accessed on October 15, 2011 (English).