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
Joined: Mar 17, 2000
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
Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
Joined: May 29, 2001
Thanks Ajit, It is quite intresting and I`ll go more in depth in this. Regards, Milan Doshi
Joined: Oct 05, 2001
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 ]
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep
Joined: Oct 05, 2001
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....