XML data access or DB data access ?

Discussion in 'ASP .Net' started by Savvoulidis Iordanis, Jan 7, 2009.

  1. Hi there. I'm creating a ASP.NET site in VS2008 (using VB), which is used
    similarly to a stock exchange application, only with less data to handle each
    minute.

    My problem consists of choosing the right path, between having my data
    (readonly) in XML files for my users, or retrieving the values from the DB,
    in each postback.

    The data is pretty static, which means after my admin users insert them,
    there are very rare changes. Then, the operators read them, so they produce
    other data for DB insertion. There is no statistical usage of the readonly
    data. In fact, they are deleted every three days, so the new readonly data
    are setup by the admins.

    The path i'm thinking of choosing, is using the XML storage (although new to
    using XML), and display the data inside gridview controls, but I have two
    fears, so I need some help by more experienced programmers in such a case:

    F1. What about the file locking issue when the admin is trying to recreate
    the XML file after doing some changes (although rare as I said)? I have a lot
    of users wanting to read data.

    F2. Is it possible to update a couple of specific nodes in the XML file
    (along with their subelement values or attributes), based on a DB SELECT? I
    mean, a certain node branch, should be updated everytime some reference data
    in the DB changes, when updating the final XML file. That is, in the sample
    XML below:
    <Event>
    <Date>1/1/2009</Date>
    <Time>07:30</Time>
    <OddsGroup1>
    <A1>3.60</A1>
    <AX>3.60</AX>
    <A2>3.60</A2>
    </OddsGroup1>
    <OddsGroup2>
    <A1>4.20</A1>
    <AX>6.20</AX>
    <A2>2.30</A2>
    </OddsGroup1>
    </Event>

    I want to update the data inside <OddsGroup1> based on a DB select from a
    reference table (Select A1,AX,A2 from ...). How is it done in ASP.NET (VB)?

    TIA
    Iordanis
     
    Savvoulidis Iordanis, Jan 7, 2009
    #1
    1. Advertising

  2. Savvoulidis Iordanis

    sloan Guest

    If you think out your application a little, you can design it so that the
    backend *datastore* becomes more trivial.

    Here is my complete example for download:
    http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!176.entry

    .........

    Instead of "raw xml"ing the thing, you can also do this:


    Create a strong dataset.
    Use the ds.ReadXml and ds.WriteXml methods.


    Let's say you create a OrganizatonDS (as a strong dataset)
    You add an Employee (table)
    You add a few columns.

    EmpKey int
    LastName string
    FirstName string
    SSN string

    Then you can add data to the strong dataset like this:

    OrganizatonDS ds = new OrganizatonDS ();

    OrganizatonDS.Employee.EmployeeRow row = ds.Employee.NewEmployeeRow();
    row.EmpKey = 111;
    row.LastName = "Smith";
    row.FirstName = "John";
    row.SSN = "222222222";

    ds.Employee.AddNewEmployeeRow (row);

    ds.Employee.AddNewEmployeeRow ( 222 , "Jones", "Mary", "333333333");

    ds.WriteXml ("C:\mydata.xml");

    ..........
    and then

    OrganizatonDS ds = new OrganizatonDS ();
    ds.ReadXml( "C:\mydata.xml"):
    Console.Writeline(ds.GetXml());




    .....................

    Depending on your data, I would still stick with a database. As you illude,
    an xml is suspect to corruption.
    Its not a definate "no no", and it might work for you.

    If you use the method I mention above (the URL to the blog entry), then you
    don't pigeon hole yourself into a specific datastore.


    Good luck.





    "Savvoulidis Iordanis" <> wrote
    in message news:...
    > Hi there. I'm creating a ASP.NET site in VS2008 (using VB), which is used
    > similarly to a stock exchange application, only with less data to handle
    > each
    > minute.
    >
    > My problem consists of choosing the right path, between having my data
    > (readonly) in XML files for my users, or retrieving the values from the
    > DB,
    > in each postback.
    >
    > The data is pretty static, which means after my admin users insert them,
    > there are very rare changes. Then, the operators read them, so they
    > produce
    > other data for DB insertion. There is no statistical usage of the readonly
    > data. In fact, they are deleted every three days, so the new readonly data
    > are setup by the admins.
    >
    > The path i'm thinking of choosing, is using the XML storage (although new
    > to
    > using XML), and display the data inside gridview controls, but I have two
    > fears, so I need some help by more experienced programmers in such a case:
    >
    > F1. What about the file locking issue when the admin is trying to recreate
    > the XML file after doing some changes (although rare as I said)? I have a
    > lot
    > of users wanting to read data.
    >
    > F2. Is it possible to update a couple of specific nodes in the XML file
    > (along with their subelement values or attributes), based on a DB SELECT?
    > I
    > mean, a certain node branch, should be updated everytime some reference
    > data
    > in the DB changes, when updating the final XML file. That is, in the
    > sample
    > XML below:
    > <Event>
    > <Date>1/1/2009</Date>
    > <Time>07:30</Time>
    > <OddsGroup1>
    > <A1>3.60</A1>
    > <AX>3.60</AX>
    > <A2>3.60</A2>
    > </OddsGroup1>
    > <OddsGroup2>
    > <A1>4.20</A1>
    > <AX>6.20</AX>
    > <A2>2.30</A2>
    > </OddsGroup1>
    > </Event>
    >
    > I want to update the data inside <OddsGroup1> based on a DB select from a
    > reference table (Select A1,AX,A2 from ...). How is it done in ASP.NET
    > (VB)?
    >
    > TIA
    > Iordanis
     
    sloan, Jan 7, 2009
    #2
    1. Advertising

  3. Thanks for poping in.

    The application is about betting on sports events. The data is about 1000
    master records (events), each having about 30 detail records (odds), for a
    3-day readonly usage. Players pick from the odds list and create the betting
    slips which are stored in the DB for further usage. They reside all over the
    country (so far ~300 are waiting for the site to complete! Oh God!). The
    point is while it doesn't seem like a large number of hits per minute or
    second, when it comes to choosing an event to bet on, most of the users wait
    until the last 1-2 available minutes to decide and finally send a bet. After
    the event starts, it's no longer available, so it must be excluded from the
    list of events (either not included in the XML file, or marking it as
    unavailable in the DB)

    The XML file is created in the beginning of the 3-day period and again only
    if some odds change (rare). Also, when an odd changes, the change must
    immediately be reflected to the user gridviews, so I think any records
    caching, or EnableViewState is out of the question.

    So, is the XML road, the best way to go in my case Isn't a XML file served
    faster than DB data?

    TIA
     
    Savvoulidis Iordanis, Jan 7, 2009
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page