Would be a good idea to model the three on XML and store complete trees on the dbms? (thinking loud!) :)