Docsity

Hypergraphs-Distributed Queries-Lecture Slides, Slides of Distributed Database Management Systems

Toggle sidebar
bg1
Hypergraphs
Hypergraph
= nodes plus (hyper)edges that are
sets of anynumber of nodes.
Applications include optimizing queries
that are joins and representing \universal
relations" (a useful data-modeling concept).
Typically, nodes represent attributes and
hyperedges are sets of attributes.
Example
Suppose wehave relations with schemas
ABC
,
ACD
, and
BE
. This database schema could be
represented by the hypergraph
A B
C
E
D
Acyclic Hypergraphs
These have some useful properties that make
query optimization easier than the general case.
Most \natural" queries correspond to acyclic
hypergraphs.
Denition depends on
GYO reduction
; GYO =
Graham-Yu-Ozsoyoglu.
An
ear
is a hyperedge
H
such that we can
divide its nodes into two groups: those that
appear in
H
and no other hyperedge and
those that are contained in another hyperedge
G
.
✦
Note that an isolated edge is an ear; no
G
is needed.
GYO reduction of a hypergraph is the process
of repeatedly nding ears and removing them.
That is, we remove those nodes that are in the
ear and no other hyperedge; then we remove
the hyperedge itself, leaving the other nodes.
✦
Wesay that ear
H
is
consumed
by
G
,if
all the nodes that are not unique to
H
are in
G
.
✦
If a hypergraph is reduced to nothing
1
docsity.com
pf3
pf4
pf5

Partial preview of the text

Download Hypergraphs-Distributed Queries-Lecture Slides and more Slides Distributed Database Management Systems in PDF only on Docsity!

Hyp ergraphs

Hypergraph = no des plus (hyp er)edges that are sets of any numb er of no des.

 Applications include optimizing queries that are joins and representing \universal relations" (a useful data-mo deling concept).

 Typically, no des represent attributes and hyp eredges are sets of attributes.

Example

Supp ose we have relations with schemas AB C , AC D , and B E. This database schema could b e represented by the hyp ergraph

A B

C

E

D

Acyclic Hyp ergraphs

These have some useful prop erties that make query optimization easier than the general case. Most \natural" queries corresp ond to acyclic hyp ergraphs.

De nition dep ends on GYO reduction; GYO = Graham-Yu-Ozsoyoglu.

 An ear is a hyp eredge H such that we can divide its no des into two groups: those that app ear in H and no other hyp eredge and those that are contained in another hyp eredge G. F Note that an isolated edge is an ear; no G is needed.

 GYO reduction of a hyp ergraph is the pro cess of rep eatedly nding ears and removing them. That is, we remove those no des that are in the ear and no other hyp eredge; then we remove the hyp eredge itself, leaving the other no des.

F We say that ear H is consumed by G, if all the no des that are not unique to H are in G. F If a hyp ergraph is reduced to nothing

1

by GYO reduction, then it is said to b e acyclic.

F Aside: \acyclic" makes sense: if the hyp ergraph is an ordinary graph, it is acyclic i it is a tree.

Example

Here is an acyclic hyp ergraph

A

B C

E

F

D

 The central hyp eredge D E F can consume each of the other three hyp eredges.

 At that time, the remaining hyp eredge is trivially an ear, since all of its no des are unique to it.

Formal GYO Reduction

The original de nition of GYO reduction consisted of the following two steps:

  1. Eliminate a no de that is in only one hyp eredge.
  2. Delete a hyp eredge that is contained in another.

The goal is to reduce a hyp ergraph to a single, empty hyp eredge.

 You need to lo ok at GYO reduction this way to show that there is a unique GYO reduction of any hyp ergraph, acyclic or not. F Key idea of pro of: candidates for step (1) remain candidates, no matter what other steps are taken.

Dangling Tuple Elimination

 Useful as a rst step in optimizing large joins.

Example

Consider AB = f 00 ; 11 g, B C = f 00 ; 11 g, and AC = f 01 ; 10 g.

 Any two relations are join-consistent. E.g., AB ./ AC = f 001 ; 110 g, which pro jected onto AB is f 00 ; 11 g.

 But AB ./ B C ./ AC = ;, so the relations are not globally consistent.

Reduction by Semijoins

If we are to take the join of several relations, it is often ecient to rst remove the dangling tuples.

 It guarantees that whatever order we join in, the result never shrinks. Thus, the total work is prop ortional to the output, and we can't do more than a constant factor b etter than that.

 To reduce relations to globally consistent subsets, we can use the semijoin op eration: R := R ><^ S = R (R ./ S ) = R ./

R (S )

 Sometimes, semijoins don't help eliminating dangling tuples. F For example, AB , B C , and AC ab ove are not changed by any semijoin.

 However, if the hyp ergraph is acyclic, the following algorithm pro duces a ful l reducer for a set of relations. F That is, the result is a set of globally join- consistent relations.

  1. Pick an ear E that can b e consumed by hyp eredge H. Execute the semijoin H := H ><^ E.
  2. Recursively generate a full reducer for the hyp ergraph with E removed.
  3. App end the semijoin E := E ><^ H.

Example

Consider the relation schemas AB C , AC D , and D E.

 AC D is an ear that is consumed by AB C.

 In the resulting hyp ergraph, AB C can b e consumed by B E.

 The full reducer:

AB C := AB C ><^ AC D B E := B E ><^ AB C AB C := AB C ><^ B E AC D := AC D ><^ AB C

Pro of It Works

 After step (1), it is imp ossible for the join of the remaining hyp eredges to have a tuple that do esn't join with any tuple of E.

 Inductively, step (2) leaves the relations other than E in a globally join-consistent state.

 Then, step (3) eliminates from E any tuples that do not join with the other relations.