1. Colorado Technical University
MAT200-0802B-02, Discrete Mathematics, Phase 3 Task #2
Group #3: Loren Schwappach, Gregory Shelton, Sammie Snowden,
Richard Wallace, Jonathan Woodard
TerraCorp Memorandum
To: V-Machine
From: TerraCorp Group
Date: 06/12/08
Re: Explanation of Database Elements
Message:
Our team of test engineers, database experts, and computer programmers at TerraCorp has
developed the following document to explain several elements of database design. The
document is broken down into two sections. The first section covers database relations and
functions and the second covers trees and tree structures.
Section 1: Relations and functions:
Part A: What are Relations and Functions?
A relation is a relationship between two sets of information (Stapel, 2008).
Whenever two objects are seen to form some kind of connection the connection is known
as a relation. A relation uses ordered pairs to show some kind of relationship shared
between the pairs. For example the ordered pair, (Bald, Man), says that some Men are
bald. Bald is known as the domain or (x) value, and Man is the range or (y) value. In a
relation the range can have multiple domains and a domain can have multiple ranges. In
database terms this relationship is known as a 1:M, M:M, or M:1 relationship, where M
refers to multiple. The graph of a relation is very simple. Here is an example showing a
1:M relationship between the (x) and (y) values:
1
2. MAT200-0802B-02 Group 3
Figure 1: 1:M Relationship
A function has the same basic definition as a relation. However, a function must
meet certain rules to be called a function. A function can be called a “well behaved
relation” (Stapel, 2008). This is due to the relationships between the domain and range.
To be a function a relation domain must have only one range. For instance in the relation
ordered pair, (Bald, Man), unique identifiers will have to be added to only allow for a 1:1
relationship. This ordered pair, (Man, Bald), guarantees that only one range is paired
with the domain. A graph representing a function is shown below where the (x) value
only has one unique value of (y). A function can also be portrayed using a parabola. As
long as the domain only has one range the graph qualifies as a function.
Figure 2: Function
2
3. MAT200-0802B-02 Group 3
All functions can be a relation, however not all relations can be functions. The
relation (Birthdays, Students) can be an M:1 relationship. This is not a function because
more than one student (range) can have the same birthday (domain). To make this a
function we can change Students to be the domain and add School, student id or even
leave birthdays as the range. If we use school then all students will return the same value
for the range. However, it is still only one value. A graph showing this function would
be a straight horizontal line. If we used student id then the students will have unique
ranges. This is a better example of a function.
Given the following Client and Engine type data (Referenced in Parts B, C, D, E):
Clients = {VRoomHouse, MyRides, NifftyRods, AllFastAuto, Bumper2Bumper}
Engines = {ZR2, XTurbo, Omy442, Rokit350}
Part B: Binary Relation between Clients and Engines:
a. ( ZR2, VRoomHouse), (ZR2, MyRides)
b. (XTurbo, MyRides), (XTurbo, NifftyRods)
c. (Omy442, NifftyRods), (Omy442, AllFastAuto)
d. (Rokit350, AllFastAuto), (Rokit350, Bumper2Bumper)
Part C: Function of Clients and Engines:
a. (VRoomHouse, ZR2)
b. (MyRides, XTurbo)
c. (NiftyRods, Omy442)
3
4. MAT200-0802B-02 Group 3
d. (AllFastAuto, Rokit350)
e. (Bumper2Bumper, ZR2)
Part D: Diagraph of the function from Part C:
VRoomHouse ZR2
MyRides Xturbo
NiftyRods Omy442
AllFastAuto Rokit350
Bumper2Bumper
Figure 3: Function directed graph
Part E: Diagraph of the relation from Part B:
ZR2 VRoomHouse
Xturbo MyRides
Omy442 NiftyRods
Rokit350 AllFastAuto
Bumper2Bumper
(Hauskrecht, 2006)
Figure 4: Binary directed graph
Section 2: Trees and Tree Structures:
Part A: What is a Tree and what is the difference between binary and n-ary trees?
Trees also known as tree-graphs are powerful creations used for the visualization,
structure, and development of database systems. Trees offer an organized approach to
object and element relationships.
4
5. MAT200-0802B-02 Group 3
According to CTU trees are a subset of graphs and normally have exactly one
vertex referred to as the root (not all trees have roots) and with directed edges referred to
as branches that head downwards towards other vertices (children). (CTU Online, 2008)
Dependent upon the depth of the tree, as the tree branches flow downwards each branch
will connect to lower level vertex. If this vertex spans additional branches it is known as
a fork, if the vertex does not span additional branches it is known as a leaf. One last
requirement of a tree is that it must not contain any cycles (explained later). Trees offer
amazing features for navigating, searching, and sorting within a database.
Figure 5: Tree-graph
CTU classifies n-ary tree-graphs as tree-graphs where each vertex can have n
children vertices connected to it. (CTU Online, 2008) CTU classifies binary tree-graphs
as tree-graphs where no vertex connects to more than two children vertices. (CTU
Online, 2008) Our team has illustrated this on the next page.
5
6. MAT200-0802B-02 Group 3
Figure 6: Binary vs. N-ary trees
Part B: Hierarchical database using a tree structure:
As illustrated by the example tree graph, trees can contain data hierarchies to
assist in searching, sorting, and navigating through the tree.
CEO
Secretary Vice
President
Secretarial Administrative Treasurer
Assistant Assistant
Client 1 Client 2 Client n
Figure 7: Hierarchical database tree structure
6
7. MAT200-0802B-02 Group 3
Part C: Traversing a tree (depth-first search and breadth-first search methods):
There are many different ways to traverse and search a tree. Some of the easiest
ways to search through a tree are the breadth-first and depth-first searches. The Breadth-
First search moves through all of the vertices or children on a given level before going to
the next level. With this type of search you would start at the root of the tree and start
searching, moving to all of the children of the root at level 2 before moving on to their
children at level 3. With the breadth-first search, the tree is searched without testing
against the goal until the solution is found. This makes it a very slow way to search a tree
(Johnsonbaugh, 2009).
Depth-first searches also start at the root of a tree but instead of traveling through
each level one at a time this search travels through a path that takes it to the greatest
height for that path, and then backtracks until it can find another path that it has not
explored to travel. This is continued until all paths have been traced. The depth-first
search is also searches without testing against the goal until the solution is found
(Johnsonbaugh, 2009).
There are faster ways to search a tree but the breadth-first and depth-first searches
are exhaustive searches. If we were to use one of these analyze a chess game I would
choose the breadth-first search as it will allow me to look at the next few move options
instead of following one move-path all the way to the end. This will allow me to adapt if
a player decides to make an unexpected move.
7
8. MAT200-0802B-02 Group 3
References:
CTU Online, (2008). Multimedia Material, Retrieved Jun, 10, 2008, from Colorado Technical
University Web site: https://campus.ctuonline.edu
Hauskrecht, M. (2006). CS 441 Discrete Mathematics for CS Lecture 34: Relations. Retrieved
June 11, 2008, from http://www.cs.pitt.edu/~milos/courses/cs441/lectures/Class34.pdf
Web site: http://www.cs.pitt.edu/~milos/courses/cs441/lectures/Class34.pdf
Johnsonbaugh, R. (2009). Discrete Mathematics (7th ed.). Upper Saddle River, New Jersey:
Pearson Prentice Hall.
Stapel, E. (2008). Functions versus relations. Retrieved June 2, 2008, from Purplemath Web site:
http://www.purplemath.com/modules/fcns.htm
Weisstein, E. (2005). Binary tree. Retrieved June 10, 2008, from Wolfram MathWorld Web site:
http://mathworld.wolfram.com/BinaryTree.html
Weisstein, E. (2005). Planted tree. Retrieved June 10, 2008, from Wolfram MathWorld Web site:
http://mathworld.wolfram.com/PlantedTree.html
Weisstein, E. (2005). Rooted tree. Retrieved June 10, 2008, from Wolfram MathWorld Web site:
http://mathworld.wolfram.com/RootedTree.html
Weisstein, E. (2005). Tree. Retrieved June 10, 2008, from Wolfram MathWorld Web site:
http://mathworld.wolfram.com/Tree.html
Attachments: None
8