Nested Relations
-
Upload
tara-nelson -
Category
Documents
-
view
9 -
download
1
description
Transcript of Nested Relations
NestedRelations: 1
Nested Relations
• Flat schemas often have replicated data values in their relations.
• Nested schemas allow us to collapse some of these replicated data values.
NrBeds RoomNr (NrBeds ( RoomNr )* )* 2 1 2 1 2 2 2 2 3 3 1 4 1 4 1 5 5
NestedRelations: 2
Redundancy in Nested Schemes• The redundancy definition is the same as for flat relations.• If a hidden value can be uniquely determined or if a value change
causes a constraint violation, the value is redundant.
RoomNr ViewNrBeds RoomNr ViewNrBeds
(NrBeds (RoomNr (View)* )* )* 2 1 Sea Forest City
2 Sea Forest
3 City
(View (RoomNr NrBeds)* )* Sea 1 2
2 2
Forest 1 2 2 2
City 1 2 3 2
NestedRelations: 3
NNF: Redundancy Free Nested Schemas
Input: a canonical, acyclic, binary hypergraph H.
Output: a set of nested schemas with no potential redundancy.
Repeat Mark an unmarked node in H as the first attribute in a new nested schema. While an unmarked edge is incident on a marked node A: Mark the edge. If A B: Add B with A; Mark B. If A B: Add B with A; Mark B if all B’s incident edges are marked. If A B: Nest B under A; Mark B. Else (A — B): Nest B under A; Mark B if all B’s incident edges are marked.Until all nodes have been marked
NestedRelations: 4
Nested Schema Generation Example
GuestNr GuestNameRoomNr
ViewCostRoomName
NrBeds GuestNr GuestNameRoomNr
ViewCostRoomName
NrBeds
1. (NrBeds, (RoomNr, RoomName, Cost, (View)*, (GuestNr, GuestName)* )* )*
2. (RoomNr, RoomName, Cost, NrBeds, (View)*, (GuestNr, GuestName)* )*
3. (GuestNr, GuestName, RoomNr)* (RoomNr, RoomName, Cost, NrBeds (View)* )*
NestedRelations: 5
Redundancy Prevention
xa 1
yb 2
z
(A ( B C )* )* a x 1
y 1 2
b y 1 2
z 2This replication ...
… causes thisredundancy.
NestedRelations: 6
Generalizationfor N-ary Relationship Sets
C
B
A D
C
B
A D
• “Composite nodes” can be treated as a single node.– (B C (A)* (D)* )*– (D (B C)* )*; (A B C)*
• Or, n-ary edges (n3) can be converted to an object set and n binary relationship sets.
• NNF, basically:– Schemes should be constructed along hypergraph paths.– Schemes should not violate the natural 1-many hierarchical structure.