next up previous
Next: Functions Up: Querying with Complex Types Previous: Path Expressions

Nesting and Unnesting

  1. The transformation of a nested relation into 1NF is called unnesting.
  2. Example. To complete unnest the doc relation, we have

     
    		 select name, A as author, date.day, date.month, date.year, 
    	K as keyword
    

    from doc as B, B.author-list as A, B.keyword-list as K

  3. The reverse operation of transformation of a 1NF relation into a nested relation is called nesting.
  4. Example. To nest the relation flat-doc on the attribute keyword, we have

     
    		 select title, author, (day, month, year) as date, 
    	set(keyword) as keyword-list
    

    from flat-doc

    groupby title, author, date

    This wil generate the following table.

    table237

  5. Example. To convert flat-doc back to the nested table doc, we have

     
    		 select title, set(author) as author-list, 
    	(day, month, year) as date, 
    	set(keyword) as keyword-list
    

    from flat-doc

    groupby title, date



Osmar Zaiane
Tue Jul 7 15:03:55 PDT 1998