60 likes | 255 Views
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
E N D
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
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. (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
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
Nested Schema Generation Example 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)* )*
Redundancy Prevention x a 1 y b 2 z (A ( B C )* )* a x 1 y 1 2 b y 1 2 z 2 … causes this redundancy. This replication ...
Generalizationfor N-ary Relationship Sets • “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.