473,608 Members | 2,410 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_Sta rt 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 1701
"Yehia A.Salam" <ye*****@hotmai l.comwrote in message
news:C3******** *************** ***********@mic rosoft.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*****@hotmai l.comwrote in message
news:C3******** *************** ***********@mic rosoft.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_Sta rt 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**@markNOSPA Mrae.netwrote in message
news:OC******** ******@TK2MSFTN GP05.phx.gbl...
"Yehia A.Salam" <ye*****@hotmai l.comwrote in message
news:C3******** *************** ***********@mic rosoft.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.ukwr ote 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*****@hotmai l.comwrote in message
news:C3******** *************** ***********@mic rosoft.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_Sta rt 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*****@hotmai l.comwrote in message
news:F8******** *************** ***********@mic rosoft.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.ukwr ote 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*****@hotmai l.comwrote in message
news:C3******* *************** ************@mi crosoft.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
initializin g the class in Global.asax in the Application_Sta rt 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*****@hotmai l.comwrote in message
news:56******** *************** ***********@mic rosoft.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**@markNOSPA Mrae.netwrote in message
news:up******** ******@TK2MSFTN GP03.phx.gbl...
"Yehia A.Salam" <ye*****@hotmai l.comwrote in message
news:56******** *************** ***********@mic rosoft.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.ukwr ote 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 .SelectSingleNo de 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.space s.live.com/Blog/cns!A68482B9628 A842A!148.entry
and after you read it (its quick) you could do something like

MyStronglyTyped DS ds = new MyStronglyTyped DS();
ds.Authors.Sele ct ("LastName=' " + "Smith" + "');

Alot less Xpath stuff.
4. Look at this also:
http://sholliday.space s.live.com/Blog/cns!A68482B9628 A842A!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*****@hotmai l.comwrote in message
news:C3******** *************** ***********@mic rosoft.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_Sta rt 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
4940
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 Install From Script. In this method I create the database and its objects in scripts that are run via osql utility on the SQL server machine. For loading any initial data that I need in the database I also run bcp commands.
2
1523
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 programing skills to the next level. I can build forms and bind data to them from SQL server, but somehow this seems not to be the best way to use an OO programming language. I guess the professional way of doing it is to have classes for each of the...
136
9285
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 code was littered with document.all and eval, for example, and I wanted to create a practical list of best practices that they could easily put to use. The above URL is version 1.0 (draft) that resulted. IMO, it is not a replacement for the FAQ,...
346
16464
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
3433
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 somewhere that each folder under the "web site" is compiled in separate assembly. I however, did not find that the "web site" creation in vs.net 2005 created any AssemblyInfo.cs file.
4
2608
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 simplest example of my situation (real world would be more complex). Say you have two versions of your application. A release version and a development version. After a month of developing you are ready to release a new version. There have...
4
2962
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 necessitate significant customization of any off-the-shelf application. In the end, we decided it would be more feasible to build one to our specifications. What I am looking for are a list of best practices/recommendations for the architecture...
3
2234
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 Enterprise Libraries data layer (if possible) - Use of providers (if possible) - use of factories (if possible) - use of caching - Session management
8
2748
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
1274
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 am just looking to see some best practice solutions that are out there to get some better ideas on how I want to be approaching this. Most often it seems when I find something with regards to this topic, it's quite limited. I'd like to see some...
0
8067
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8501
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8157
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8349
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6820
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
3967
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4030
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2477
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1336
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.