I have an xml file format that looks something like this:<topLevelTag>  <category name=foo>    <item attrib=value>ItemName</item>    <item attrib=value2>AnotherItem</item>  </category>  <category name=bar>    <item attrib=value>ItemName</item>    <item attrib=value2>AnotherItem</item>  </category></topLevelTag>The code that parses this creates an instance of ItemName and is told that it's one category is, in the first case, foo, and then creates a second instance of ItemName which has associated category bar. The problem is that I need to redesign the system so that each Item can have more than one Category. But I still need to be able to create multiple items as well. For example (using bullets instead of xml) I might need to create the following instances:ItemNamePrimary Category - fooSecondary Category - barItemNamePrimary Category - barSecondary Category - fooItemNamePrimary Category - fooSecondary Category - quuxAnotherItemPrimary Category - bazSecondary Category - fooTertiary Category - monkeyetc ... (no cap)StillAnotherItemetc ...etc ... (no cap)How can I design my XML format to encapsulate this many-to-many relationship?I am aware this question is on the borderline between StackOverflow and Programmers. I chose to put it here because it is a software architecture and design question. If not please let me know and I'll be happy to move it. Precedent one | Precedent two | Precedent three
Converting a one-to-many xml design to a many-to-many
design;xml;data modeling