This step by step tutorial shows you how to run BaseX in client-server mode from a terminal. You can copy & paste the commands to get it running on your machine. After you finished this tutorial, you will be familiar with the basic administration of BaseX. Visit the [[Commands|commands section]] for a complete list of database commands.
==Start BaseX Server server and Clientclient==
Please have a look at the [[Startup Overview]], and start a server and a client instance of BaseX.
Databases are stored in the BaseXData directory which is located in your home folder. Depending on your operating system the location of your home folder varies. For example, on a mac it's /Users/John, if your name is John.
==Execute a Queryquery==
The [[Commands|xquery]] command lets you run a query.
* For example, this query returns all country nodes in the currently opened database.
</code>
==Create a new Databasedatabase==
Now we will create another database. You can find the example document here: [http://phobos101.inf.uni-konstanz.de/basex/demo].
</code>
==Switch the Databasedatabase==
* You can explicitly query the factbook database with the doc()-funtion, no matter what the current context is.
<code>
</pre>
==Close or delete a Databasedatabase==
* To [[Commands|close]] the current context database type:
<code>
</code>
==Create a Collectioncollection==
'''What is a collection?'''
With BaseX you can group documents into one logical collection. A collection is a database that contains two or more documents. Collections accept any type of XML documents, regardless of their structure.
</code>
==Delete a Documentdocument==
* Deleting a document from a collection is very easy:
<code>
Make sure the collection which contains the xmark.xml document is opened.
==Delete a Collectioncollection==
Deleting a collection is the same as deleting a database.
</code>
==Get Server Informationserver information==
Several commands help to explore the state of a server. For a complete list visit the [[Commands|commands section]].
</code>
==Backup and Restorerestore==
To backup your database, type:
:<code>