XML data access or DB data access ?

XML data access or DB data access ?

Post by U2F2dm91bG » Fri, 09 Jan 2009 00:53:01

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

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:

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)?


XML data access or DB data access ?

Post by Mark Rae [ » Fri, 09 Jan 2009 01:24:44

"Savvoulidis Iordanis" < XXXX@XXXXX.COM > wrote

There's a school of thought which says that it's a really good idea to use
technology for the purpose for which it was designed. Although XML files can
be used to store data, they aren't a database - not even close. You could
use Excel to write a novel, but you wouldn't...

How much data are we talking about...?

Mark Rae


XML data access or DB data access ?

Post by sloa » Fri, 09 Jan 2009 01:58:47

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:


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"):


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" < XXXX@XXXXX.COM > wrote
in message news: XXXX@XXXXX.COM ...


XML data access or DB data access ?

Post by U2F2dm91bG » Fri, 09 Jan 2009 07:47:29

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?


XML data access or DB data access ?

Post by Mark Rae [ » Fri, 09 Jan 2009 08:03:07

"Savvoulidis Iordanis" < XXXX@XXXXX.COM > wrote


I wouldn't say so... Since the data is relatively small, I'd probably just
store it in your site's Application cache. That way, it only has to be
"read" once - thereafter, it's already in memory...

Generally speaking, no...

Mark Rae