Data Shaping

  • Where is the data shaping really useful?

    Has anyone used data shaping in live environment. Please do let me know your experiences.

    Thankx

    Paras Shah

    Evision Technologies

    Mumbai, India


    Paras Shah
    Evision Technologies
    Mumbai, India

  • Leon has some experience with it - I'll get him to post some comments.

    Andy

  • Thankx I shall await his replies.

    quote:


    Leon has some experience with it - I'll get him to post some comments.

    Andy


  • My experience is that it works very well but I can only think of very few nitch situations where I would consider using it because of the complexity. Also I have been playing some with sql2000 "for xml" which is capable of producing similar results as a shaped record set. I not sure if one syntax is any better than the other yet. XML is definately easier to use once retreived than the shaped recordset but I think the retreival syntax may be just a slight bit more complicated.

    One word of advise is you need to be carefull with shaped recordsets because you may be returning much more data than you think. For example unless your child query is takes into consideration the results of the parent query the recordset will contain all records that match the child query not just the records that are related to the parent. (you will only see the related records through the ADO object model but the unrelated data is still there hidden somewhere in the underlying recordset. I had an interesting situation relating to this when I was trying to export a shaped recordset to excel using excels "CopyFromRecordset" method. It appears that this method uses some kind of backdoor into a recordset that is not accessable through the standard ADO interface because using it returned all of my child records even those that were not related to the parent records) If this is unclear let me know and I will attempt to explain. (Note: this leads to one advantage of XML, you dont have any excess data hanging around that is not relevant. In fact in the application mentioned I ended up saving my shaped recordset out to XML and then re-opening it to clear out the garbage.)

    One further word - It may be easier to write code to process the records individually rather than using SQL to try processing them as a set. The Only time I see for using a shaped recordset is if you absolutely have to process hierarchical data as a set. Even then if you are using SQL2000 consider returning the results as xml if your hierarchy is not very complicated.

  • Qestion 1> Why in the first place has MS introduced Data Shaping? Is it required?

    Question 2> In what situtations does shaping take up a lead role where other methods fail?

    Please, lets discuss this. Thankx

    Paras Shah

    Evision Technologies

    Mumbai, India


    Paras Shah
    Evision Technologies
    Mumbai, India

  • I'd say for two reasons. One is that you're making one trip across the wire, not a couple hundred as you loop through the outer recordset to get the "child" and "grandchild" records - I'll grant there are way to do it fairly efficiently without shaping, but I think a lot of people do it badly and shaping is a nice way to get it done efficiently.

    The other is that sometimes you really are working with a hierarchy and it's nice to work with it that, both conceptually and practically. For those of you not familiar with it child records are contained in a recordset that appears as a "field" in the main/parent recordset where it has a field type of....136 I think.

    So lets forget the shape syntax for a minute, just think of the stereotypical order/order detail situation - we want to get all the orders from yesterday and all the details. Once we get that into a shaped recordset, it might look like this:

    do until rsOrderInfo.eof

    debug.print rsOrderInfo.OrderID, rsOrderInfo.Status, blah, blah

    set rsTemp=rsOrderINfo!OrderDetails

    do until rstemp.eof

    debug.print rsTemp!Qty, rsTemp!Description

    rstemp.movenext

    loop

    set rsTemp=nothing

    rsOrderInfo.movenext

    loop

    I'm not an XML guy (that's Leon!), and I think that the shape syntax is far cleaner than the FOR XML with the EXPLICIT option. It also lets me skip the XML DOM learning curve. I think probably a good compromise if you need XML is to retrieve using Shape, then apply a transform to the XML generated by the recordset.

    We were flat stunned when we found out we were bringing over tons more data than we needed - but it makes sense if you think about it!

    Andy

  • One other comment on this matter. I don't really think data shaping was ever that popular and look for it to disappear. If you have looked at the next version of ADO (thats ADO+) you will find that ADO has a DataSet object which has a collection of tables and a collection of relations. This should be by far the simplest method of retreiving and manipulating hierachical data. It seems like it will be almost like working with a database itself.

  • This seems really nice! But is ADO+ a part of .NET technology or would it also work with ASP 3.0? What do I need to install to use ADO+?

    quote:


    One other comment on this matter. I don't really think data shaping was ever that popular and look for it to disappear. If you have looked at the next version of ADO (thats ADO+) you will find that ADO has a DataSet object which has a collection of tables and a collection of relations. This should be by far the simplest method of retreiving and manipulating hierachical data. It seems like it will be almost like working with a database itself.


    Paras Shah

    Evision Technologies

    Mumbai, India


    Paras Shah
    Evision Technologies
    Mumbai, India

  • Unfortunately it is currently only available with the .NET Framework.

Viewing 9 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic. Login to reply