# Relational algebra

## Relational Division

There are four approaches to manipulating relational databases, namely, Relational algebra, relational calculus, SQL, and QBE.

SQL (Structured query language) is the most popular query language that manipulates data in a relational database; While QBE (Query by example) is a fill-in-the-blanks approach to questioning a database. The user searches for information by filling out a query form on the display screen. QBE is developed by Microsoft and used in Microsoft Access database system.Relational algebra and Relational calculus are less widely used, because they are more difficult to use than SQL, and the WYSIWYG (what-you-see-is-what-you-get) query language QBE.

As the name of the manipulationa language implies, Relational algebra has a set of operations similar to traditional algebra (e.g., add minus, multiply, and divide). Relational algebra a standard for judging other data retrieval language, such as SQL. There are eight relational algebra operations that can be used with either one or two relations to create a new relation: restrict, project, product, union, intersect, difference, join, and divide. Among these, divide is the hardest relational operator to understand.

Division is in principle a partitioning operation. Thus 9/3 means partitioning a single group of 9 into a number of groups of 3 - in this case, 3 groups of 3. 9 is the dividend and 3 is divisor. As the name of this operation implies, relational division involves dividing one relation by another. Division requires that A and B have a set of attributes that are common to both relations.

In following case, relation A and B have the same set of attributes Y. Conceptually, A divided by B asks the question:

"Is there a value in the X column of A (e.g., x1) that has a value in the Y column of A for every value of y in the Y column of B?" This can be illustrated as bellow:

A

-----------

X Y

-----------

x1 y1

x1 y3

x1 y2

x2 y1

x3 y3

-----------

B

-----

Y

-----

y1

y2

----

A DIVIDE B

----------

X

----------

x1

----------

When you examine the X column of A, you find there there are rows (x1,y1) and (x1, y2). That is, for x1, there is a value in the Y column of A for every value of y in the Y coloumn of B. Thus, the result of the division is a new relation with a single row and column containing the value x1.

In this example, we can ask an alternative question, "which values of X share the subset {y1,y2} of Y?" By inspecting relation A, we can verify that only x1 of X has corresponding Y entries of both 'y1' and 'y2'. Put another way, the tuples of A are grouped by the common denominator or divisor (y1,y2). This can be shown in the relation A' - which is an intermediate result of division:

A'

-----------

X Y

-----------

x1 y1

x1 y2

-----------

Division does not always yield whole groups of the divisor, e.g., 7 รท 2 gives 3 groups of 2 and a remainder group of 1. Relational division too can leave remainders but, much like integer division, we ignore remainders and focus only on constructing whole groups of the divisor. In this case, other tuples (the remainder of the division) are ignored. Thus the result is x1.

Reference:

Richard T. Watson Data Management, Databases and Organization, John Wiley & Sons, Inc.

http://elqui.dcsc.utfsm.cl/util/Database_Design/rdbh06.htm

## More by this Author

- 4
I use Virgin Media (VM) for my broadband, TV, and Telephone. I use a wireless router for my home network. I have three laptops. In this article, I will share with you some of my knowledge that I have learnt through...

- 0
Frost is a p2p app that works on top of Freenet. You need to have Freenet working to use Frost. Freenet is an Network over the Internet which provides true anonymity. With starting Freenet on your machine you are...

- 14
Learn why your gas fire keeps going out even when it still seems on and how to fix this.

## Comments

No comments yet.