What's the diff between Database and collection
Tuesday, 8 November 2011 · 10 messages · last reply 10 Nov 2011
EF
Edward Fong8 Nov 2011 05:40 #
Hi,
What's the diff between Database and collection? I think there are same in baseX, am I right?
And how to query by a document name?
Following are steps of my testing:
1: loaded some xml files form a directory: d:\data\org-*.xml 2: query by doc('org-100525.xml') and got File or directory "D:/Program Files (x86)/BaseX701/bin/org-100525.xml" not found message.
3: because after loaded xml, directory: d:\data\org-*.xml was removed. I can't query by doc('d:\data\org-100525.xml')
Thanks,
Edward
MS
Michael Seiferle8 Nov 2011 10:07 #
Hi Edward,
thanks for you email.
Quoted text · Edward Fong · 3 lines
Am 08.11.2011 um 05:40 schrieb Edward Fong: > Hi, > What's the diff between Database and collection? I think there are same in baseX, am I right?
close, a database contains one document node, while a collection is allowed to contain several document nodes. You can easily create a collection by creating a database from a source directory, by running the following command. CREATE db collection-test /path/to/xml-directory
To query individual file inside that collection you can use the following:
for $doc in collection('test/input.xml')
return base-uri($doc)To query each file inside your collection run the following: for $doc in collection('test')
return base-uri($doc)
Where 'test' is the name of the collection and '/input.xml' is the path to the document inside this collection.
I hope this helps, feel free to ask for more information as needed.
Kind regards
Michael
Quoted text · Edward Fong · 13 lines
> And how to query by a document name? > Following are steps of my testing: > 1: loaded some xml files form a directory: d:\data\org-*.xml > 2: query by doc('org-100525.xml') and got File or directory "D:/Program Files (x86)/BaseX701/bin/org-100525.xml" not found message. > 3: because after loaded xml, directory: d:\data\org-*.xml was removed. I can't query by doc('d:\data\org-100525.xml') > > Thanks, > Edward > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
JC
Jan Vlčinský (CAD)8 Nov 2011 10:21 #
What a great question and answer.
Additional question: what is relation between the only document in the database, and collection of documents, stored in that database.
Is it like this?: *database contains one document, this document is/defines collection of documents.*
Am I correct?
Jan Vlčinský
Quoted text · Michael Seiferle · 59 lines
On 8 November 2011 10:07, Michael Seiferle <michael.seiferle at uni-konstanz.de > wrote: > Hi Edward, > > thanks for you email. > Am 08.11.2011 um 05:40 schrieb Edward Fong: > > Hi, > What's the diff between Database and collection? I think there are same > in baseX, am I right? > > close, a database contains one document node, while a collection is > allowed to contain several document nodes. > You can easily create a collection by creating a database from a source > directory, by running the following command. > CREATE db collection-test /path/to/xml-directory > > To query individual file inside that collection you can use the following: > > for $doc in *collection*('*test*/input.xml') > return base-uri($doc) > > To query each file inside your collection run the following: > for $doc in *collection*('*test*') > return base-uri($doc) > > > Where '*test*' is the name of the collection and '/input.xml' is the path > to the document inside this collection. > > I hope this helps, feel free to ask for more information as needed. > > Kind regards > Michael > > And how to query by a document name? > Following are steps of my testing: > 1: loaded some xml files form a directory: d:\data\org-*.xml > 2: query by doc('org-100525.xml') and got File or directory "D:/Program > Files (x86)/BaseX701/bin/org-100525.xml" not found message. > 3: because after loaded xml, directory: d:\data\org-*.xml was removed. I > can't query by doc('d:\data\org-100525.xml') > > Thanks, > Edward > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk > > > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk > >
CG
Christian Grün8 Nov 2011 10:33 #
Hi Jan, hi all,
I forgot to post my last (and short) answer to Edward to the list.. We have created a small entry in our Wiki that is supposed to answer questions around databases in BaseX:
http://docs.basex.org/wiki/Databases
In BaseX, a single database contains an arbitrary number of resources, addressed by their unique database path. Resources can either be XML documents or raw files (binaries). As sets of XML documents are also called collections, a BaseX database may either contain a single collection. When new collections are added to the database, they will be represented in the same directory hierarchy.
We have recently added new functions to simplify the access to resources within databases:
-- The db:open() function returns documents that are found in a database --
fn:collection() either returns documents of a database or of the specified location
-- fn:doc() returns a single document, or opens a database for this specific document. In the latter case, the database may only contain the one addressed document.
I hope this answers some more questions; you are welcome to ask for more (..or edit the Wiki entry in question if you feel that it's incomplee ;).
ChristianQuoted text · Jan Vlčinský (CAD) · 69 lines
On Tue, Nov 8, 2011 at 10:21 AM, Jan Vlčinský (CAD) <jan.vlcinsky at cad-programs.com> wrote: > What a great question and answer. > Additional question: what is relation between the only document in the > database, and collection of documents, stored in that database. > Is it like this?: database contains one document, this document is/defines > collection of documents. > Am I correct? > Jan Vlčinský > > On 8 November 2011 10:07, Michael Seiferle > <michael.seiferle at uni-konstanz.de> wrote: >> >> Hi Edward, >> thanks for you email. >> Am 08.11.2011 um 05:40 schrieb Edward Fong: >> >> Hi, >> What's the diff between Database and collection? I think there are same >> in baseX, am I right? >> >> close, a database contains one document node, while a collection is >> allowed to contain several document nodes. >> You can easily create a collection by creating a database from a source >> directory, by running the following command. >> CREATE db collection-test /path/to/xml-directory >> To query individual file inside that collection you can use the following: >> for $doc in collection('test/input.xml') >> return base-uri($doc) >> To query each file inside your collection run the following: >> for $doc in collection('test') >> return base-uri($doc) >> >> Where 'test' is the name of the collection and '/input.xml' is the path to >> the document inside this collection. >> I hope this helps, feel free to ask for more information as needed. >> Kind regards >> Michael >> >> And how to query by a document name? >> Following are steps of my testing: >> 1: loaded some xml files form a directory: d:\data\org-*.xml >> 2: query by doc('org-100525.xml') and got File or directory "D:/Program >> Files (x86)/BaseX701/bin/org-100525.xml" not found message. >> 3: because after loaded xml, directory: d:\data\org-*.xml was removed. I >> can't query by doc('d:\data\org-100525.xml') >> >> Thanks, >> Edward >> >> _______________________________________________ >> BaseX-Talk mailing list >> BaseX-Talk at mailman.uni-konstanz.de >> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >> >> >> _______________________________________________ >> BaseX-Talk mailing list >> BaseX-Talk at mailman.uni-konstanz.de >> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >> > > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk > >
JC
Jan Vlčinský (CAD)8 Nov 2011 10:45 #
Christian
The very first definition of the term database in the wiki is clarifying my question perfectly.
Thanks
Jan
Quoted text · Christian Grün · 107 lines
On 8 November 2011 10:33, Christian Grün <christian.gruen at gmail.com> wrote: > Hi Jan, hi all, > > I forgot to post my last (and short) answer to Edward to the list.. We > have created a small entry in our Wiki that is supposed to answer > questions around databases in BaseX: > > http://docs.basex.org/wiki/Databases > > In BaseX, a single database contains an arbitrary number of resources, > addressed by their unique database path. Resources can either be XML > documents or raw files (binaries). As sets of XML documents are also > called collections, a BaseX database may either contain a single > collection. When new collections are added to the database, they will > be represented in the same directory hierarchy. > > We have recently added new functions to simplify the access to > resources within databases: > > -- The db:open() function returns documents that are found in a database > -- fn:collection() either returns documents of a database or of the > specified location > -- fn:doc() returns a single document, or opens a database for this > specific document. In the latter case, the database may only contain > the one addressed document. > > I hope this answers some more questions; you are welcome to ask for > more (..or edit the Wiki entry in question if you feel that it's > incomplee ;). > > Christian > ___________________________ > > On Tue, Nov 8, 2011 at 10:21 AM, Jan Vlčinský (CAD) > <jan.vlcinsky at cad-programs.com> wrote: > > What a great question and answer. > > Additional question: what is relation between the only document in the > > database, and collection of documents, stored in that database. > > Is it like this?: database contains one document, this document > is/defines > > collection of documents. > > Am I correct? > > Jan Vlčinský > > > > On 8 November 2011 10:07, Michael Seiferle > > <michael.seiferle at uni-konstanz.de> wrote: > >> > >> Hi Edward, > >> thanks for you email. > >> Am 08.11.2011 um 05:40 schrieb Edward Fong: > >> > >> Hi, > >> What's the diff between Database and collection? I think there are > same > >> in baseX, am I right? > >> > >> close, a database contains one document node, while a collection is > >> allowed to contain several document nodes. > >> You can easily create a collection by creating a database from a source > >> directory, by running the following command. > >> CREATE db collection-test /path/to/xml-directory > >> To query individual file inside that collection you can use the > following: > >> for $doc in collection('test/input.xml') > >> return base-uri($doc) > >> To query each file inside your collection run the following: > >> for $doc in collection('test') > >> return base-uri($doc) > >> > >> Where 'test' is the name of the collection and '/input.xml' is the path > to > >> the document inside this collection. > >> I hope this helps, feel free to ask for more information as needed. > >> Kind regards > >> Michael > >> > >> And how to query by a document name? > >> Following are steps of my testing: > >> 1: loaded some xml files form a directory: d:\data\org-*.xml > >> 2: query by doc('org-100525.xml') and got File or directory "D:/Program > >> Files (x86)/BaseX701/bin/org-100525.xml" not found message. > >> 3: because after loaded xml, directory: d:\data\org-*.xml was removed. I > >> can't query by doc('d:\data\org-100525.xml') > >> > >> Thanks, > >> Edward > >> > >> _______________________________________________ > >> BaseX-Talk mailing list > >> BaseX-Talk at mailman.uni-konstanz.de > >> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk > >> > >> > >> _______________________________________________ > >> BaseX-Talk mailing list > >> BaseX-Talk at mailman.uni-konstanz.de > >> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk > >> > > > > > > _______________________________________________ > > BaseX-Talk mailing list > > BaseX-Talk at mailman.uni-konstanz.de > > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk > > > > >
EF
Hi all,
May be my question about the diff bewteen database and collection make many people confused.
I post this question because I was confused by the structure of baseX's database.
And I'm litle clear about the structure.
And another question: base-uri() return the string value based on Input Path of database. and the base-uri was different if I loaded same data from different folder. why the base-uri() does not return it's path in the database? And is there any function to query document in database by base-uri value?
And what does the input path used for?
database cqp and fong was created with CREATE DATABASE [name] [input], but edward with CREATE DATABASE [name].
Thanks for your replying, And hope BaseX become more and more popular.
Edward
Quoted text · Christian Grün · 100 lines
on 2011/11/8 17:33, Christian Grün Wrote: > Hi Jan, hi all, > > I forgot to post my last (and short) answer to Edward to the list.. We > have created a small entry in our Wiki that is supposed to answer > questions around databases in BaseX: > > http://docs.basex.org/wiki/Databases > > In BaseX, a single database contains an arbitrary number of resources, > addressed by their unique database path. Resources can either be XML > documents or raw files (binaries). As sets of XML documents are also > called collections, a BaseX database may either contain a single > collection. When new collections are added to the database, they will > be represented in the same directory hierarchy. > > We have recently added new functions to simplify the access to > resources within databases: > > -- The db:open() function returns documents that are found in a database > -- fn:collection() either returns documents of a database or of the > specified location > -- fn:doc() returns a single document, or opens a database for this > specific document. In the latter case, the database may only contain > the one addressed document. > > I hope this answers some more questions; you are welcome to ask for > more (..or edit the Wiki entry in question if you feel that it's > incomplee ;). > > Christian > ___________________________ > > On Tue, Nov 8, 2011 at 10:21 AM, Jan Vlčinský (CAD) > <jan.vlcinsky at cad-programs.com> wrote: >> What a great question and answer. >> Additional question: what is relation between the only document in the >> database, and collection of documents, stored in that database. >> Is it like this?: database contains one document, this document is/defines >> collection of documents. >> Am I correct? >> Jan Vlčinský >> >> On 8 November 2011 10:07, Michael Seiferle >> <michael.seiferle at uni-konstanz.de> wrote: >>> Hi Edward, >>> thanks for you email. >>> Am 08.11.2011 um 05:40 schrieb Edward Fong: >>> >>> Hi, >>> What's the diff between Database and collection? I think there are same >>> in baseX, am I right? >>> >>> close, a database contains one document node, while a collection is >>> allowed to contain several document nodes. >>> You can easily create a collection by creating a database from a source >>> directory, by running the following command. >>> CREATE db collection-test /path/to/xml-directory >>> To query individual file inside that collection you can use the following: >>> for $doc in collection('test/input.xml') >>> return base-uri($doc) >>> To query each file inside your collection run the following: >>> for $doc in collection('test') >>> return base-uri($doc) >>> >>> Where 'test' is the name of the collection and '/input.xml' is the path to >>> the document inside this collection. >>> I hope this helps, feel free to ask for more information as needed. >>> Kind regards >>> Michael >>> >>> And how to query by a document name? >>> Following are steps of my testing: >>> 1: loaded some xml files form a directory: d:\data\org-*.xml >>> 2: query by doc('org-100525.xml') and got File or directory "D:/Program >>> Files (x86)/BaseX701/bin/org-100525.xml" not found message. >>> 3: because after loaded xml, directory: d:\data\org-*.xml was removed. I >>> can't query by doc('d:\data\org-100525.xml') >>> >>> Thanks, >>> Edward >>> >>> _______________________________________________ >>> BaseX-Talk mailing list >>> BaseX-Talk at mailman.uni-konstanz.de >>> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >>> >>> >>> _______________________________________________ >>> BaseX-Talk mailing list >>> BaseX-Talk at mailman.uni-konstanz.de >>> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >>> >> >> _______________________________________________ >> BaseX-Talk mailing list >> BaseX-Talk at mailman.uni-konstanz.de >> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >> >>
CG
Christian Grün8 Nov 2011 17:05 #
Hi Edward,
Quoted text · Edward Fong · 2 lines
> May be my question about the diff bewteen database and collection make many people confused. > I post this question because I was confused by the structure of baseX's database.
questions like this are welcome; they often help us to improve our documentation. Do you think that the current Wiki information gives you all the relevant information you need?
Quoted text · Edward Fong · 1 line
> And another question: base-uri() return the string value based on Input Path of database. and the base-uri was different if I loaded same data from different folder. why the base-uri() does not return it's path in the database?
XQuery itself has no database semantics, and the implementation of the doc() and collection() are mostly implementation defined, which is why the base-uri() returns confusing information if documents in databases are addressed. To explicitly open documents in a database, I recommend to use db:open(), or
db:list() to retrieve all resources within a database [1].
Hope this helps,
Christian
[1] http://docs.basex.org/wiki/Database_FunctionsEF
Hi,
I set up a baseX db server on 192.168.11.11 by basexserver.bat But failed to connect it with following codes:
org.basex.api.xqj.BXQDataSource xqs = new
org.basex.api.xqj.BXQDataSource();
xqs.setProperty("user", "admin");
xqs.setProperty("password", "passwd");
xqs.setProperty("serverName", "192.168.11.11");
xqs.setProperty("port", "1984");
// Build a connection to the specified driver.
XQConnection conn = xqs.getConnection();
// Prepare the expression with the document and the query.
XQPreparedExpression expr = conn.prepareExpression(QUERY);It seems that xqj of basex only access to it's embbed basex db, right? If not please tell me how to.
Thanks,
Edward
CG
Christian Grün9 Nov 2011 18:21 #
Hi Edward,
Quoted text · Edward Fong · 2 lines
> It seems that xqj of basex only access to it's embbed basex db, right? If > not please tell me how to.
True, the client/server architecture is not supported; please see here as well:
http://docs.basex.org/wiki/Code_Examples
Christian
EF
Edward Fong10 Nov 2011 02:52 #
Hi Christian,
Thanks for your answer.
Best wishes,
Edward
Quoted text · Christian Grün · 10 lines
On 2011/11/10 1:21, Christian Grün Wrote: > Hi Edward, > >> It seems that xqj of basex only access to it's embbed basex db, right? If >> not please tell me how to. > True, the client/server architecture is not supported; please see here as well: > > http://docs.basex.org/wiki/Code_Examples > > Christian
Written for BaseX 7.0. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery