473,398 Members | 2,403 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

XML Database Best Practices

Hello,

I am building an ASP.net website that connects to an XML database, and was
wondering which is the best way to create the connection if I need frequent
access to the database, I have one of the three options:

1. Use one instance of XmlDocument thought the whole Application by
initializing the class in Global.asax in the Application_Start Event.
2. Use one instance per session using the Session_Start Event.
3. Create and initialse the XmlDocument as late as possible and close it as
soon as possible, by creating a new instance and close each time per access.

I I know that if I were using SQL database I would go with option 3 because
of the connection pooling and the security concerns, but this feature is not
available for XmlDatabases AFAIK, should I depend on the caching features of
ASP.net? , what is best design of the three to use?

Thanks
Yehia A.Salam

May 30 '07 #1
9 1690
"Yehia A.Salam" <ye*****@hotmail.comwrote in message
news:C3**********************************@microsof t.com...
I I know that if I were using SQL database I would go with option 3
because of the connection pooling and the security concerns, but this
feature is not available for XmlDatabases AFAIK, should I depend on the
caching features of ASP.net? , what is best design of the three to use?
Well, the obvious first question is why are you using XML as a database...?
That is absolutely not what it's designed for...
--
http://www.markrae.net

May 30 '07 #2
Your best option is to use a database. XML is good for holding some data but
its not a good option as a replacement for a database when your expecting
read and write operations.

If you really need to use an XML file as a data store, get used to how
asp.net uses caching and take advantage of it. If it doesn't change, then
use the app object - if it does, use caching and expire it as required. My
site uses RSS as the data feed for its content, and caches and expires the
data hourly - but there's no write operations so thats OK.

Regards

John Timney (MVP)
http://www.johntimney.com
http://www.johntimney.com/blog
"Yehia A.Salam" <ye*****@hotmail.comwrote in message
news:C3**********************************@microsof t.com...
Hello,

I am building an ASP.net website that connects to an XML database, and was
wondering which is the best way to create the connection if I need
frequent access to the database, I have one of the three options:

1. Use one instance of XmlDocument thought the whole Application by
initializing the class in Global.asax in the Application_Start Event.
2. Use one instance per session using the Session_Start Event.
3. Create and initialse the XmlDocument as late as possible and close it
as soon as possible, by creating a new instance and close each time per
access.

I I know that if I were using SQL database I would go with option 3
because of the connection pooling and the security concerns, but this
feature is not available for XmlDatabases AFAIK, should I depend on the
caching features of ASP.net? , what is best design of the three to use?

Thanks
Yehia A.Salam

May 30 '07 #3
that's what I though but I have no other options as this is a university
project and I'm stuck with XML

"Mark Rae" <ma**@markNOSPAMrae.netwrote in message
news:OC**************@TK2MSFTNGP05.phx.gbl...
"Yehia A.Salam" <ye*****@hotmail.comwrote in message
news:C3**********************************@microsof t.com...
>I I know that if I were using SQL database I would go with option 3
because of the connection pooling and the security concerns, but this
feature is not available for XmlDatabases AFAIK, should I depend on the
caching features of ASP.net? , what is best design of the three to use?

Well, the obvious first question is why are you using XML as a
database...? That is absolutely not what it's designed for...
--
http://www.markrae.net
May 30 '07 #4
that's what I though but I have no other options as this is a university
project and I'm stuck with XML, you mean it's best to use one instance
through the whole application lifetime?

"John Timney (MVP)" <x_****@timney.eclipse.co.ukwrote in message
news:-a*********************@eclipse.net.uk...
Your best option is to use a database. XML is good for holding some data
but its not a good option as a replacement for a database when your
expecting read and write operations.

If you really need to use an XML file as a data store, get used to how
asp.net uses caching and take advantage of it. If it doesn't change, then
use the app object - if it does, use caching and expire it as required.
My site uses RSS as the data feed for its content, and caches and expires
the data hourly - but there's no write operations so thats OK.

Regards

John Timney (MVP)
http://www.johntimney.com
http://www.johntimney.com/blog
"Yehia A.Salam" <ye*****@hotmail.comwrote in message
news:C3**********************************@microsof t.com...
>Hello,

I am building an ASP.net website that connects to an XML database, and
was wondering which is the best way to create the connection if I need
frequent access to the database, I have one of the three options:

1. Use one instance of XmlDocument thought the whole Application by
initializing the class in Global.asax in the Application_Start Event.
2. Use one instance per session using the Session_Start Event.
3. Create and initialse the XmlDocument as late as possible and close it
as soon as possible, by creating a new instance and close each time per
access.

I I know that if I were using SQL database I would go with option 3
because of the connection pooling and the security concerns, but this
feature is not available for XmlDatabases AFAIK, should I depend on the
caching features of ASP.net? , what is best design of the three to use?

Thanks
Yehia A.Salam

May 30 '07 #5
if its fixed data - stick it in the app object.

Regards

John Timney (MVP)
http://www.johntimney.com
http://www.johntimney.com/blog
"Yehia A.Salam" <ye*****@hotmail.comwrote in message
news:F8**********************************@microsof t.com...
that's what I though but I have no other options as this is a university
project and I'm stuck with XML, you mean it's best to use one instance
through the whole application lifetime?

"John Timney (MVP)" <x_****@timney.eclipse.co.ukwrote in message
news:-a*********************@eclipse.net.uk...
>Your best option is to use a database. XML is good for holding some data
but its not a good option as a replacement for a database when your
expecting read and write operations.

If you really need to use an XML file as a data store, get used to how
asp.net uses caching and take advantage of it. If it doesn't change,
then use the app object - if it does, use caching and expire it as
required. My site uses RSS as the data feed for its content, and caches
and expires the data hourly - but there's no write operations so thats
OK.

Regards

John Timney (MVP)
http://www.johntimney.com
http://www.johntimney.com/blog
"Yehia A.Salam" <ye*****@hotmail.comwrote in message
news:C3**********************************@microso ft.com...
>>Hello,

I am building an ASP.net website that connects to an XML database, and
was wondering which is the best way to create the connection if I need
frequent access to the database, I have one of the three options:

1. Use one instance of XmlDocument thought the whole Application by
initializing the class in Global.asax in the Application_Start Event.
2. Use one instance per session using the Session_Start Event.
3. Create and initialse the XmlDocument as late as possible and close it
as soon as possible, by creating a new instance and close each time per
access.

I I know that if I were using SQL database I would go with option 3
because of the connection pooling and the security concerns, but this
feature is not available for XmlDatabases AFAIK, should I depend on the
caching features of ASP.net? , what is best design of the three to use?

Thanks
Yehia A.Salam


May 30 '07 #6
"Yehia A.Salam" <ye*****@hotmail.comwrote in message
news:56**********************************@microsof t.com...
that's what I thought but I have no other options as this is a university
project and I'm stuck with XML
That makes absolutely no sense whatsoever!

Why can't you use a Jet database (sometimes called an Access database), or
SQL Server Compact Edition...?
--
http://www.markrae.net

May 30 '07 #7
I would hazzard a guess its an assignment and it includes a non-optional
need to use an XML file source.

Regards

John Timney (MVP)
http://www.johntimney.com
http://www.johntimney.com/blog
"Mark Rae" <ma**@markNOSPAMrae.netwrote in message
news:up**************@TK2MSFTNGP03.phx.gbl...
"Yehia A.Salam" <ye*****@hotmail.comwrote in message
news:56**********************************@microsof t.com...
>that's what I thought but I have no other options as this is a university
project and I'm stuck with XML

That makes absolutely no sense whatsoever!

Why can't you use a Jet database (sometimes called an Access database), or
SQL Server Compact Edition...?
--
http://www.markrae.net

May 31 '07 #8
"John Timney (MVP)" <x_****@timney.eclipse.co.ukwrote in message
news:TY******************************@eclipse.net. uk...
>I would hazzard a guess its an assignment and it includes a non-optional
need to use an XML file source.
Hmm - yes, you are probably right...
--
http://www.markrae.net

May 31 '07 #9

Barring what the others have said about "use a real database", here is what
I would do:
1. If the xml is pretty stable, then you could put it in the Application[]
object.

What I usually do is write a method:
public void XmlDocument GetTheDocument( bool forceRefresh )
{

//if the object is in the Application cache, return it

//if the object is not in the cache, create it , put it in the cache

//if the bool forceRefresh is set to true, ignore whats in the
Application object, get the freshest, put it in the cache for future people
}
2. If you want to query on it, then you'll have to write some XPath
statements, and use .SelectSingleNode or .SelectNodes
Working wiht xpath's and nodes is ... heavier than I like. So let's go to
#3

3. If the xml is in a format you can't control, you may be able to massage
it into DataSet friendly xml.
Why? If you could take the xml, make it DataSet friendly, and create a
strongly typed dataset for the data, you could have an object you can work
against.
For Select's and Row additions and such.

See
http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!148.entry
and after you read it (its quick) you could do something like

MyStronglyTypedDS ds = new MyStronglyTypedDS();
ds.Authors.Select ("LastName='" + "Smith" + "');

Alot less Xpath stuff.
4. Look at this also:
http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!125.entry

You can easily convert it to use Application (instead of Session). And have
a smarter holder.
Throw in some 2.0 Generics, and you can get slick with it.
That code is just a fancy wrapper for the Session object. But I like it
alot better than coding directly against the Session[] object.



"Yehia A.Salam" <ye*****@hotmail.comwrote in message
news:C3**********************************@microsof t.com...
Hello,

I am building an ASP.net website that connects to an XML database, and was
wondering which is the best way to create the connection if I need
frequent
access to the database, I have one of the three options:

1. Use one instance of XmlDocument thought the whole Application by
initializing the class in Global.asax in the Application_Start Event.
2. Use one instance per session using the Session_Start Event.
3. Create and initialse the XmlDocument as late as possible and close it
as
soon as possible, by creating a new instance and close each time per
access.
>
I I know that if I were using SQL database I would go with option 3
because
of the connection pooling and the security concerns, but this feature is
not
available for XmlDatabases AFAIK, should I depend on the caching features
of
ASP.net? , what is best design of the three to use?

Thanks
Yehia A.Salam

May 31 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: great_googley_moogley | last post by:
Greetings, I am in the process of installing a SQL database at a customer location. I have determined that there are 3 ways to do this, and I wanted to know which is the best of the 3. 1...
2
by: hplloyd | last post by:
I am fairly new to VB.NET programming but have built many database applications in Access SQL Server etc. I need to find a good book or other reference material that will help me take my OO...
136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
346
by: rkusenet | last post by:
http://biz.yahoo.com/rc/040526/tech_database_marketshare_1.html Interesting to see that database sales for windows is more than Unix.
10
by: jojobar | last post by:
Hello, I am trying to use vs.net 2005 to migrate a project originally in vs.net 2003. I started with creation of a "web site", and then created folders for each component of the site. I read...
4
by: Collin Peters | last post by:
I have searched the Internet... but haven't found much relating to this. I am wondering on what the best practices are for migrating a developmemnt database to a release database. Here is the...
4
by: DeepDiver | last post by:
I am developing an inventory database in SQL Server. I realize there are many commercial (as well as some non-commercial) inventory offerings, but my client has specific requirements that would...
3
by: John Dalberg | last post by:
I am looking for an ASP.NET application on CodePlex which exemplifies best practices for the following: - Use of interfaces - Seperation of the UI, business and data tiers - Data Tier that uses...
8
by: situ | last post by:
Hello all, i have Database1 and database2, is it possible to make database connection to database2 by running stored procedure on database1. Thanks and Regards Situ
1
by: =?Utf-8?B?R3JlZw==?= | last post by:
Are there any sample projects or web-sites out there that discuss best practices with regards to inserting, editing and deleting records in a database with VB.Net. I know how I can do all this, I...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.