• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

XML or the Database ?

 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Friends,
An intresting interview question which was asked to me.
Let us say that there is an XML Document which contains the same piece of information as contained in an Employee table of a particular database. If I send a querry as to Select all the Marketing personnels working in India and having Salary less than X amount. Then in which case will the output be faster and why ?
I am not a pro in XML and an indepth reply will help me to understand things better.
Thanks in advance,
Regards,
Milan Doshi
 
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The answer really depends on how big the XML document is. Since the XML document is just a plain flat text-based entity, it will not have advanced features otherwise present in relational databases such as indexing, search optimization etc. Having said that, one can always build XML documents to facilitate quick searching. For instance, frequently used search fields can be assigned unique IDs in the document.
If you compare two scenarios ie., sending the resultset as an XML document versus sending the SQL query and have the end user execute the query, the pros and cons can be summarized as follows -
  • The XML document can be used any number of times once it is received at the other end ; whereas the SQL will have to be tweaked and executed each time the user wishes to see a variation of the result set.
  • By not giving the actual SQL to the user, you can avoid sharing database access details such as user id, password, instance information etc with the user who is by the way, only interested in data, not how to procure the data.
  • With some good design, we can let the user reformat the XML for any desired presentation while not changing the underlying data. SQL resultsets do not offer this flexibility unless you introduce a facade of formatting logic.
  • Last but not the least, delivering the data as XML and not as a set of SQL statements help you achieve a greater degree of data abstraction. If your table structures change in future, you don't have to "fix" the SQL and send it to all the 100 client bases again!


  • Hope this gives you some food for thought
     
    Doshi Milan
    Ranch Hand
    Posts: 112
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Thanks Ajit,
    It is quite intresting and I`ll go more in depth in this.
    Regards,
    Milan Doshi
     
    Ranch Hand
    Posts: 445
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    It is more interesting for me is that XSLT can query XML just as SQL language does with database.
    Cheers,
    Doug.
    [ January 17, 2002: Message edited by: Doug Wang ]
     
    Doug Wang
    Ranch Hand
    Posts: 445
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Originally posted by Ajith Kallambella:
    If you compare two scenarios ie., sending the resultset as an XML document versus sending the SQL query and have the end user execute the query, the pros and cons can be summarized as follows -

    Ajith, one more pro of XML I'd like to supplement is,
    When you get the XML document of your resultset, you can send it to end users of any platform, that is, you may send it to Windows user, Linux user, Mac user, or....

    Doug.
    reply
      Bookmark Topic Watch Topic
    • New Topic