I am designing a database to store XML elements and attributes.
Created May 4, 2012
Luigi Viggiano Create a table as this:
table ELEMENT ELEM-ID number(9) primary key, ELEM-NAME char(30), ELEM-CONTENTS char(30), PARENT-ID number(9), (references another ELEM-ID) table ATTRIBUTE ATTR-ID number(9) primary key, ATTR-NAME char(30), ATTR-VALUE char(30), ELEM-OWNER-ID number(9), (refrences an ELEM-ID)
Elements with null in PARENT-ID are root's elements, so you can make a query selecting null in PARENT-ID to get the list of root's elements.
To get all the children of an element you have to select all elements having parent-id = your elem-id.
Attributes are referenced 1 to many with Elements.