Two basic questions
Tuesday, 25 September 2012 · 4 messages
GM
Garey Mills25 Sep 2012 00:59 #
I am contemplating using BaseX from a web application using the Java API. I plan to use it, among other things, to store some information on the users of the site. Someone coming in to the application would be asked to identify themselves, probably with an email address. Based on the address, I would find a record stored in BaseX and possibly edit the record.
So my question is: would it be better to have a collection of small XML documents, one to each user; or does BaseX provide the concurrent access control to allow me to have one document with any number of user records?
Second question: I seen in the Java API examples how to create a new database, but I don't see an easy way to check if a database exists. Does that mean, then, that I should create the databases beforehand and then assume they exist inside my application?
My apologies in advance, since I am sure these question have been asked before. The list archive search function on the BaseX site is not working.
--
Garey Mills
Library Systems Office
UC Berkeley
CG
Christian Grün25 Sep 2012 03:27 #
Dear Garey,
Quoted text · Garey Mills · 3 lines
> would it be better to have a collection of small XML > documents, one to each user; or does BaseX provide the concurrent access > control to allow me to have one document with any number of user records?
the transaction management of BaseX will ensure that there won't be any conflicts while performing updates, no matter how many
collections/databases you use for your data. Size matters, however: if a single collection is expected to occupy several gigabytes, it's often wise to split it up into several database instances to speed up querying and indexing.
Quoted text · Garey Mills · 4 lines
> Second question: I seen in the Java API examples how to create a new > database, but I don't see an easy way to check if a database exists. Does > that mean, then, that I should create the databases beforehand and then > assume they exist inside my application?
Exactly; as most XQuery functions assume that the processed databases already exist, the usual approach is to first create databases and access them after that. If you want to check if a database exist, you can e.g. use the LIST command,
db:list(), or db:open(), surrrounded by a try/catch statement in XQuery.Quoted text · Garey Mills · 2 lines
> My apologies in advance, since I am sure these question have been asked > before. The list archive search function on the BaseX site is not working.
No problem, your questions are always welcome. I've updated the mailing list links to point to the Mail Archive, which will be frequently updated [1].
Christian
[1] http://www.mail-archive.com/basex-talk at mailman.uni-konstanz.de/
CG
Quoted text · Garey Mills · 5 lines
> Thank you for your kind response, although I remain uncertain about the > first question. Suppose that I had the requirements that a database needed > to allow concurrent access of many users for read/update. For this purpose, > would it be better to have a collection of small XML documents or would one > large XML document work?
Currently, all write operations in BaseX are performed one after another, no matter where the data will be stored. We are working on a database-wide locking solution – which is a little bit tricky, because a single XQuery expression can be used to address one or more databases at the same time.
Some more details on our transaction management are found in our documentation:
http://docs.basex.org/wiki/Transaction_Management
Hope this helps; feel free to ask for more,
Christian
Quoted text · Christian Grün · 45 lines
> On 9/24/2012 6:27 PM, Christian Grün wrote: >> >> Dear Garey, >> >>> would it be better to have a collection of small XML >>> documents, one to each user; or does BaseX provide the concurrent access >>> control to allow me to have one document with any number of user records? >> >> the transaction management of BaseX will ensure that there won't be >> any conflicts while performing updates, no matter how many >> collections/databases you use for your data. Size matters, however: if >> a single collection is expected to occupy several gigabytes, it's >> often wise to split it up into several database instances to speed up >> querying and indexing. >> >>> Second question: I seen in the Java API examples how to create a new >>> database, but I don't see an easy way to check if a database exists. Does >>> that mean, then, that I should create the databases beforehand and then >>> assume they exist inside my application? >> >> Exactly; as most XQuery functions assume that the processed databases >> already exist, the usual approach is to first create databases and >> access them after that. If you want to check if a database exist, you >> can e.g. use the LIST command, db:list(), or db:open(), surrrounded by >> a try/catch statement in XQuery. >> >>> My apologies in advance, since I am sure these question have been >>> asked >>> before. The list archive search function on the BaseX site is not >>> working. >> >> No problem, your questions are always welcome. I've updated the >> mailing list links to point to the Mail Archive, which will be >> frequently updated [1]. >> >> Christian >> >> [1] http://www.mail-archive.com/basex-talk at mailman.uni-konstanz.de/ >> > > -- > Garey Mills > Library Systems Office > UC Berkeley >
GM
Christian -
Thank you for your kind response, although I remain uncertain about the first question. Suppose that I had the requirements that a database needed to allow concurrent access of many users for read/update. For this purpose, would it be better to have a collection of small XML documents or would one large XML document work?
In other words, how does the concurrent update of one large XML document perform?
Garey
Quoted text · Christian Grün · 33 lines
On 9/24/2012 6:27 PM, Christian Grün wrote: > Dear Garey, > >> would it be better to have a collection of small XML >> documents, one to each user; or does BaseX provide the concurrent access >> control to allow me to have one document with any number of user records? > the transaction management of BaseX will ensure that there won't be > any conflicts while performing updates, no matter how many > collections/databases you use for your data. Size matters, however: if > a single collection is expected to occupy several gigabytes, it's > often wise to split it up into several database instances to speed up > querying and indexing. > >> Second question: I seen in the Java API examples how to create a new >> database, but I don't see an easy way to check if a database exists. Does >> that mean, then, that I should create the databases beforehand and then >> assume they exist inside my application? > Exactly; as most XQuery functions assume that the processed databases > already exist, the usual approach is to first create databases and > access them after that. If you want to check if a database exist, you > can e.g. use the LIST command, db:list(), or db:open(), surrrounded by > a try/catch statement in XQuery. > >> My apologies in advance, since I am sure these question have been asked >> before. The list archive search function on the BaseX site is not working. > No problem, your questions are always welcome. I've updated the > mailing list links to point to the Mail Archive, which will be > frequently updated [1]. > > Christian > > [1] http://www.mail-archive.com/basex-talk at mailman.uni-konstanz.de/ >
--
Garey Mills
Library Systems Office
UC Berkeley
Written for BaseX 7.3. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery