Constrained Relation Browse
Randy Morey, 2010.May.15
Introduction
The purpose of constrained relation browse is to facilitate the building of queries which, upon execution, do not produce empty result relations. The relational algebra of CRB is the method of determining what values are allowable for a given query attribute. Thus, as this is a demonstration of CRB, it is never possible to select a query in the interface below which would cause an empty result relation.
A constrained relation query begins with an empty query. In this example, each attribute "drop-down" of the query relation is populated with all possible values. A change in one query attribute results in a change in the available values for all other query attributes. Attribute "drop-downs" are only populated with values which, when selected, would not produce empty result relations.
Learn about Relational Algebra
Wikipedia has an excellent introduction to relational algebra. To understand this article, you need only know about the "project" and "natural join" operators.
Formulas
Let Q1 be a relation of no more than 1 tuple with no null attribute values. Let a2 be the set of unique attributes in R1 which are not in Q1. Thus the unique relation for any attribute a in a2:
πa(R1 ⋈ Q1)
Let a1 be the set of common attributes in relations R1 and Q1. For any attribute a in a1 there is another set a3 that is the set a1 excluding a. Thus the unique relation for a in a1:
πa(R1 ⋈ πa3(Q1))
Demonstration Interface
Please interact with the "drop-downs" to observe that: 1) the result relation is never empty, and 2) the available query values are updated on each selection.
Query Relation (Q1)
Source Relation (R1)
| FirstName | Age | EyeColor | Gender |
|---|---|---|---|
| John | 72 | Blue | M |
| Mary | 56 | Blue | F |
| David | 68 | Brown | M |
| Elizabeth | 68 | Green | F |
| Sally | 50 | Brown | F |
| Michael | 75 | Brown | M |
| Mary | 19 | Brown | F |
| Peter | 68 | Blue | M |