next up previous
Next: About this document Up: My Home Page

Relations

We have seen several types of mathematical objects over the course of the semester: predicates, sets, ordered pairs, and functions.

Relations use ordered tuples to represent relationships among objects.

`` ...is a parent of ...'' - <Morris,Steve>, <Ria,Steve>

``...is a number less than ...'' - <3,42>, <42,43>

``Student number ...is named ...and majors in ...'' - <124324443,Mary,CSE>, <563565426,Mary,PSY>

``...is an even number'' ...<2>

Essentially, a relation is the set of assignments which makes a predicate true.

Binary Relations

Binary relations have two blanks, relating two objects.

More formally, suppose A and B are sets. A binary relation from A to B is a set tex2html_wrap_inline485 .

Thus R is a set of ordered pairs <a,b> where tex2html_wrap_inline491 and tex2html_wrap_inline493 .

If tex2html_wrap_inline495 then we sometimes write a R b.

Example: tex2html_wrap_inline499 , tex2html_wrap_inline501 . tex2html_wrap_inline503 is ``...in A is an integer multiple of ...in B.''

so tex2html_wrap_inline509

Presenting Binary Relations

Binary relations are particularly useful because they have two kinds of compact visual representation, tables and graphs.

tabular251

Graphs are composed of vertices or nodes connected by edges or arcs.

There is an arc from a to b iff tex2html_wrap_inline515

The Parent-Of Relation

The parent of relations, ``...is a parent of ...'', is a binary relation between pairs of people.

tabular263

Which representation is better for testing whether the pair <x,y> is in the relation?

Which representation is better for capturing the overall structure?

Reflexive Relations

A relation R on A is reflexive if a is related to a (a R a) for every tex2html_wrap_inline529 .

A relation R on A is irreflexive if a is not related to any tex2html_wrap_inline537 .

tabular274

The difference is what happens on the main diagonal of the matrix.

Is the parent relation reflexive, irreflexive, or neither?

Is the tex2html_wrap_inline539 relation reflexive, irreflexive, or neither?

Is the boss-of relation reflexive, irreflexive, or neither?

Symmetric Relations

A relation R on A is symmetric if for all tex2html_wrap_inline545 , whenever tex2html_wrap_inline547 then tex2html_wrap_inline549 .

A relation R on A is antisymmetric if for all tex2html_wrap_inline555 , if tex2html_wrap_inline557 and tex2html_wrap_inline559 , then a=b.

tabular288

In a symmetric relation, the matrix is symmetric around the main diagonal.

In an antisymmetric relation, the only symmetric entries are one the diagonal, i.e. the only back arcs are self-loops.

Is the cousin-of relation symmetric, antisymmetric, or neither?

Is the brother-of relation symmetric, antisymmetric, or neither?

Is the tex2html_wrap_inline563 relation symmetric, antisymmetric, or neither?

Transitive Relations

A relation R is transitive if for all a, b, c, if a R b and b R c, then a R c

If there is a path from a to c in a transitive relation, there must be a single arc from a to c.

Is the ancestor-of relation transitive or not?

Is the friend-of relation transitive or not?

Is the tex2html_wrap_inline587 relation transitive or not?

The transitive closure of a relation R adds all the arcs to R necessary to make it transitive.

Ancestor is the transitive closure of parent.

Special and Equivalence Relations

The universal relation tex2html_wrap_inline593 .

The empty relation tex2html_wrap_inline595 .

The identity relation tex2html_wrap_inline597

tabular314

tex2html_wrap_inline599 is an equivalence relation if it is reflexive, symmetric, and transitive.

Equivalence relations partition the elements into equivalence classes of identically-behaving elements.

The universal and identity relations are both equivalence relations.

General (n-ary) Relations

Suppose tex2html_wrap_inline603 , tex2html_wrap_inline605 , ..., tex2html_wrap_inline607 are sets. A relation of tex2html_wrap_inline609 , tex2html_wrap_inline611 , ..., tex2html_wrap_inline613 is a set tex2html_wrap_inline615 .

Thus R is a set of ordered n-tuples tex2html_wrap_inline621 where tex2html_wrap_inline623 .

Example: tex2html_wrap_inline625 , tex2html_wrap_inline627 , tex2html_wrap_inline629

``Student number ...is named ...and majors in ...''

<124324443,Mary,CSE>, <563565426,Mary,PSY>

Such structures are modeled by hypergraphs, a graph structure where each ``edge'' represents a subset of more than two vertices.

Relational Databases

The most important commercial database systems today employ the relational model, meaning that the data is stored as tables of tuples, i.e. relations.

A Shakespearian killed relation would be:

tabular325

Requests for information from the database is made in a query language like SQL which is based on the notations of set theory and the predicate calculus.

Example 1: Who killed Caesar?

In the relational algebra:

(KILLED WHERE VICTIM='Caesar')[KILLER]

This reads ``select from relation `killed' all tuples where the victim was Caesar, and report only the killer field from each.

Example 2: Who was both a killer and a victim?

In the relational algebra:

KILLED[KILLER] INTERSECT KILLED[VICTIM]

Much of the power of relational databases comes from the fact that we can combine different relations. For example, suppose we also have a died-by relation:

tabular338

We can combine the two tables with a join operation, which the tables based on common fields. For example, the join of killed and died-by is:

tabular348

Example 3: Which killers used daggers?

In the relational algebra:

( (KILLED JOIN DIED-BY) WHERE METHOD='Daggers' ) [KILLER]

Note that this database design assumes that each victim can only be killed by one weapon (sorry, Rasputin).

Modular Arithmetic

An important example of an equivalence relation is grouping integers into classes based on their remainder mod k.

Think of grouping integers by counting around a clock.

Note that tex2html_wrap_inline635 . If you start at 0 and count to 23 you end up at 11.

This is because 11 and 23 have the same remainder when divided by 12.

Note that if tex2html_wrap_inline637 and tex2html_wrap_inline639 then tex2html_wrap_inline641 - think about tracing out a path on the clock to prove it.

Consider the relation tex2html_wrap_inline643 .

This relation is reflexive, symmetric, and transitive, and hence is an equivalence relation.

What an equivalence relation means is that the elements can be partitioned into equalence classes (or blocks) such that all elements in the same block have the same properties.

tex2html_wrap_inline645 , tex2html_wrap_inline647 , ...

Total and Partial Orders

Many sets of objects, such as the integers, have a natural total order defined on them. For each pair of x and y, either (1) x > y, (2) y < x, or (3) x=y.

Such total orders can be very useful. For example, we can sort any subset of totally ordered objects uniquely, e.g. (1,5,12,14,23). The `next' element of any finite, totally ordered set is completely defined.

However, not all sets of objects have naturally defined total orders on them. Consider the set of entertainers ordered according to who is the bigger star:

Note the confusion because different types are stars are incomparable, which is not the same as equals. Several different orders are consistant with this data.

Partial Orders

tex2html_wrap_inline661 is a partial order if it is reflexive, antisymmetric, and transitive.

Examples of partial orders include ``ancestor-of'', ``less-than'', and ``divides-evenly''.

Because R is antisymmetric, there can be no cycle in R. Thus there can be no inconsistancy in the order (such as Redford-Bogart-Newman-Redford).

A partial order on n objects can have at only one consistant total ordering, or as many as n! total orderings, depending upon the pairs in the relation.

Subsets by Inclusion

For any set A, the relation tex2html_wrap_inline673 on the power set of A defines a partial order.

The structure of this subset inclusion relation defines the graph known as a hypercube.

Note the recursive structure of a hypercube; a d-dimensional cube is composed by connecting two (d-1)-dimensional cubes.




next up previous
Next: About this document Up: My Home Page

Steve Skiena
Tue Aug 24 22:10:37 EDT 1999