Difference between revisions of "Databases"

From BaseX Documentation
Jump to navigation Jump to search
Line 1: Line 1:
 
==Introduction==
 
==Introduction==
In BaseX there are two kinds of databases. It is possible to have
+
In BaseX, there are two kinds of databases. It is possible to have
 
databases with single XML files or databases with a bunch of XML files, called collections.
 
databases with single XML files or databases with a bunch of XML files, called collections.
 
In a nutshell you can say, a collection is a database with additional features, for adding, deleting
 
In a nutshell you can say, a collection is a database with additional features, for adding, deleting

Revision as of 13:38, 17 January 2011

Introduction

In BaseX, there are two kinds of databases. It is possible to have databases with single XML files or databases with a bunch of XML files, called collections. In a nutshell you can say, a collection is a database with additional features, for adding, deleting and accessing the included documents. Theses features can be seen below.

Creation of a database

You can create a database either within the GUI or in the console version of BaseX.

  • GUI: Go to Database/New and then press Browse to choose a file and press OK
  • Console: enter basex -c "create db dbname /path/to/file"

Collection

Creation of a collection

You can create a collection either within the GUI or in the console version of BaseX.

  • GUI: Go to Database/New and then press Browse to choose a directory and press OK
  • Console: enter basex -c "create db dbname /path/to/collection"

Manage Collections

Additional to the creation with your choosen xml files you can start with creating an empty collection and then add your xml files to it. Note that the add and delete commands just operate on an opened database.

Console:

  • Create an empty database: create db example
  • Add a document: add example.xml
  • Delete a document: delete example.xml

GUI: In the GUI you can execute all above operations in the Database menu.

For more information see our collection tutorial.

Access documents in collections

The XQuery collection() function can be used to access documents in collections:

  • Returning all documents of collection ("dbname"):
    for $doc in collection("dbname") return base-uri($doc)
  • Access a specific document ("test") in collection ("dbname"):
    collection("dbname/test")//*