Connecting Tech Pros Worldwide Forums | Help | Site Map

XML Database Best Practices

Yehia A.Salam
Guest
 
Posts: n/a
#1: May 30 '07
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

Mark Rae
Guest
 
Posts: n/a
#2: May 30 '07

re: XML Database Best Practices


"Yehia A.Salam" <yehiaeg@hotmail.comwrote in message
news:C3E9ED1C-7F98-4D2D-87B3-DA7C152EB2F9@microsoft.com...
Quote:
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

John Timney \(MVP\)
Guest
 
Posts: n/a
#3: May 30 '07

re: XML Database Best Practices


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" <yehiaeg@hotmail.comwrote in message
news:C3E9ED1C-7F98-4D2D-87B3-DA7C152EB2F9@microsoft.com...
Quote:
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

Yehia A.Salam
Guest
 
Posts: n/a
#4: May 30 '07

re: XML Database Best Practices


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" <mark@markNOSPAMrae.netwrote in message
news:OCVqH9voHHA.3304@TK2MSFTNGP05.phx.gbl...
Quote:
"Yehia A.Salam" <yehiaeg@hotmail.comwrote in message
news:C3E9ED1C-7F98-4D2D-87B3-DA7C152EB2F9@microsoft.com...
>
Quote:
>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
Yehia A.Salam
Guest
 
Posts: n/a
#5: May 30 '07

re: XML Database Best Practices


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_john@timney.eclipse.co.ukwrote in message
news:-aWdnYHrquBec8DbRVnyjQA@eclipse.net.uk...
Quote:
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" <yehiaeg@hotmail.comwrote in message
news:C3E9ED1C-7F98-4D2D-87B3-DA7C152EB2F9@microsoft.com...
Quote:
>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
>
>
John Timney \(MVP\)
Guest
 
Posts: n/a
#6: May 30 '07

re: XML Database Best Practices


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" <yehiaeg@hotmail.comwrote in message
news:F81B3CBF-8B48-451C-BC7E-6ED1A908B2F7@microsoft.com...
Quote:
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_john@timney.eclipse.co.ukwrote in message
news:-aWdnYHrquBec8DbRVnyjQA@eclipse.net.uk...
Quote:
>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" <yehiaeg@hotmail.comwrote in message
>news:C3E9ED1C-7F98-4D2D-87B3-DA7C152EB2F9@microsoft.com...
Quote:
>>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
>>
>>

Mark Rae
Guest
 
Posts: n/a
#7: May 30 '07

re: XML Database Best Practices


"Yehia A.Salam" <yehiaeg@hotmail.comwrote in message
news:568D600A-0C05-4B22-8B59-F08B479C8110@microsoft.com...
Quote:
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

John Timney \(MVP\)
Guest
 
Posts: n/a
#8: May 31 '07

re: XML Database Best Practices


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" <mark@markNOSPAMrae.netwrote in message
news:upt8hlwoHHA.4400@TK2MSFTNGP03.phx.gbl...
Quote:
"Yehia A.Salam" <yehiaeg@hotmail.comwrote in message
news:568D600A-0C05-4B22-8B59-F08B479C8110@microsoft.com...
>
Quote:
>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

Mark Rae
Guest
 
Posts: n/a
#9: May 31 '07

re: XML Database Best Practices


"John Timney (MVP)" <x_john@timney.eclipse.co.ukwrote in message
news:TYadnewx484hFsPbnZ2dnUVZ8tOmnZ2d@eclipse.net. uk...
Quote:
>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

sloan
Guest
 
Posts: n/a
#10: May 31 '07

re: XML Database Best Practices



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" <yehiaeg@hotmail.comwrote in message
news:C3E9ED1C-7F98-4D2D-87B3-DA7C152EB2F9@microsoft.com...
Quote:
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
Quote:
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
Quote:
soon as possible, by creating a new instance and close each time per
access.
Quote:
>
I I know that if I were using SQL database I would go with option 3
because
Quote:
of the connection pooling and the security concerns, but this feature is
not
Quote:
available for XmlDatabases AFAIK, should I depend on the caching features
of
Quote:
ASP.net? , what is best design of the three to use?
>
Thanks
Yehia A.Salam
>

Closed Thread