Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML file as a database

Status
Not open for further replies.

csutton

Programmer
Dec 27, 2000
213
US
Hi all,

I would like to know if it is possible to use an XML file as a database. If so, what concerns are there about record locking (multiuser access)?

The reason I need to do an XML file and not a normal relational DB is because each site where my program will be installed will store different information so the tables would be different, sometimes each record would have different data (as information that needs to be saved would change over time).

Should I use SQL Server and just make a table with a large field and store the XML document in there?

Thanks.
 
I would like to know if it is possible to use an XML file as a database
You could but I wouldn't recommend it. If your application is capable of changing the XML file so that fields (nodes) can be inserted and changed, then why not use this functionality to create tables in SQL Server? You could quite easily drop/create tables (defining the necessary fields along the way) and inset data into them.

If you can do this then I would definately recommend it over using an XML file.

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
Hi,

Using an XML as DB would be done by reading it into a Dataset, and using Datatable and Dataview functionality to query and manipulate it.

Kristof
 
As far as tables being altered, that is possible, however I could forsee this happening frequently that a table would need to be altered, sometimes removing fields that were once necessary but not necessary anymore.

Kristof, what about record locking, multiuser access? Is that a concern?
 
Generally speaking, you would do that with an extra 'locked' column (with a boolean value). That way you can lock at a record level, whenever required.

My first thought would be to implement this multiuser functionality using webservices.

But I agree with ca8msm that the implications of this would get very complex, compared to using a DB, as usual.
 
You'd have no record locking, and multiuser access would be unreliable. Basically, you'd have to read the XML file into a dataset at runtime. Until you decided to write it again, the XML file would stay static. IF another user opens the XML file, then you make a change and write it, his dataset won't be dynamically updated. The only way to do this would be to read in the xml to a dataset EVERY time you do an operation. This would be extremely costly.

Also the read/write XML functions begin to take a LONG TIME the larger the database gets. For VERY small single user applications it might be feasible. I wouldn't recommend this otherwise.
 
Ok, so does anyone have ideas of how to do something like this? Basically, the user will complete a form on the screen and the results need to be saved to a file, in which they can be searched, manipulated, etc. Each client may have a different form and can change their form any time they want, but I need to keep the data from previous forms even if a newer form does not have the same field.

Thank you!
 
It can be done. Using time stamps on updates on each row, a flag base locking system, and a robust precheck engine to avoid updating a row someone has checked out.

-Rick

----------------------
 
Thanks Rick, do you have any examples to share or places to go that would already have this implemented?

If not, I'll work on a design, but I'd hate to reinvent the wheel.

Thanks!
 
Nothing concrete. The big thing is to either Lock a record when someone checks it out (loads it in a place where it may be writen to or changed) or to use a time stamp any time a record is altered, then when saving the record, check to make sure that time stamp hasn't changed. Or you can use a compilation of both to ensure that a record is not changed inbetween checking the time stamp and actually saving (in that fraction of a second... it is possible, just not likely)

I'm sure there are good theories and designs in existance. Try googling arround for them.

-Rick

----------------------
 
I don't understand the resistance to using some kind of database system. Especially if this is supposed to be multi user, and the data is of a critical nature. If you don't want to go for SQL Server, use MYSQL or MSDE. There's no point trying to re-invent the wheel, or implement your own database system. You're just adding overhead to your application, and a lot more room for error.

Just my 2 cents.
 
Nips, by the sounds of it this app is going to be somewhat dynamic. That in and of itself doesn't forbid having an actual DB, but if the developer is creating a turn key solution for small organization's web sites, using an XML back end will save them tons of money from having to invest in licensing and trained professionals to setup/maintain the system.

I agree with you that it is not an optimum solution for most situations. But XML does have it's uses. Also, just because you are using a database does not mean that there is locking implimented. We have an inhouse .Net system that runs off SQL Server, it requires it's own record locking solution.

-Rick

----------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top