Difference between revisions of "Databases"

From BaseX Documentation
Jump to navigation Jump to search
(Created page with "<h3>Introduction</h3> <p>In BaseX you can create databases with single XML files or databases with a bunch of XML files, called collections. The creation, management and acces...")
 
Line 19: Line 19:
 
<ul>  
 
<ul>  
 
<li>Create an empty database: <code>create db example</code></li>  
 
<li>Create an empty database: <code>create db example</code></li>  
<li><a href="commands#add">Add</a> a document: <code>add example.xml</code></li>  
+
<li> [[Commands#Add|Add]] a document: <code>add example.xml</code></li>  
<li><a href="commands#delete">Delete</a> a document: <code>delete example.xml</code></li>  
+
<li> [[Commands#Delete|Delete]] a document: <code>delete example.xml</code></li>  
 
</ul>  
 
</ul>  
 
   
 
   
<p>For more information see our <a href="tutcolls">tutorial</a>.</p>  
+
<p>For more information see our [[BaseX & Collections|collection tutorial]].</p>  
 
   
 
   
 
<h3>Access documents in collections</h3>  
 
<h3>Access documents in collections</h3>  

Revision as of 14:54, 7 December 2010

Introduction

In BaseX you can create databases with single XML files or databases with a bunch of XML files, called collections. The creation, management and access of these collections is described in the follwing sections.

Creation of a collection

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

  • GUI: choose File » New » Browse » choose directory and press OK
  • Console: enter basex -c "create db dbname /path/to/collection"

Manage Collections

Additionaly 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.

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

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")//*