Hi Markus,

Not quite what I am aiming for.

 

We do want a single BaseX Instance to provide access to multiple databases.

Further to this though, a set of client applications will only connect to one database.
We have multiple sets of client applications, with each set each connecting to one database.

 

We do want to modularise the functions, however as an example we want to be able to have 2 versions of the same function, where 1 version works with the schema of the data in database 1, and the second version with a different schema in database 2.

 

If I could explicitly link the function modules with a database, I could call the same function from both application sets, and use the context of the open database to call the correct version of the function.

 

An example situation may help

Say we have Database for “Black Books”, which has book data in xml structures which conform to some version (1.1) of a schema.

We want a query stored on the server that returns books on art

Get-Books-About-Art

We have a client application specifically for this database that calls this function.

It will only need to query the data in this database.

 

Now we add a second Database for "Goliath Books"

The book data in this database uses a modified xml structure (version 2 of a schema)

We have a client application for this database that also wants to get books about art.

The query for this database is slightly different because the xml schema has changed.

 

I would like to store both versions of Get-Books-About-Art in the database.

Then for each client to connect to their associated database, and be able to execute the correct version of the xquery function.

 

The idea is that each time I add a new database that has data in some format, I can install associated query modules that are restricted to the context of that database to avoid conflicts with existing databases.

 

Maybe what I am looking for is effectively a database specific repo to install modules to, rather than a basex install repo.

 

From: Markus Wittenberg <wittenberg@axxepta.de>
Sent: Friday, 21 February 2020 2:15 PM
To: DYER Chris <Chris.Dyer@sydac.com>; basex-talk@mailman.uni-konstanz.de
Subject: Re: [basex-talk] Database specific xquery modules

 

A RESTXQ definition could look something like this:

declare

    %rest:path("/a/{$client}/{$path}")

function yourmodule:test($client as xs:string, $path as xs:string) {

    let $db := switch ($client)

        case "clientA" return db:open("dbA")

        case "clientA" return db:open("dbA")

        default return db:open("dbX")

    return yourmodule:do-something-with($db, $path)

};

And the called function do-something-with could also depend on the client

 

Am 21.02.2020 um 03:48 schrieb DYER Chris:

Hi Markus,

Our intent is to use REST and RESTXQ interfaces to interact with data on a single database using some server side XQueries.

 

However, we may have 2 (or more) databases provided by some server, and associated xqueries are specific to the contents of each database (as the contents of each of these databases may be structured differently).

 

We would like for a client to be able to open a single database and be able to run associated XQueries, without requiring client side knowledge of which server side xqueries are associated with the database it has opened.

 

Does this help describe what we are trying to achieve?

 

Cheers,
Chris

 

 

From: BaseX-Talk <basex-talk-bounces@mailman.uni-konstanz.de> On Behalf Of Markus Wittenberg
Sent: Friday, 21 February 2020 12:08 PM
To: basex-talk@mailman.uni-konstanz.de
Subject: Re: [basex-talk] Database specific xquery modules

 

 Hi Chris,

as you might already know, BaseX has built-in REST support [1] which you can use to query and update data via HTTP. You can also use the RESTXQ [2] functionality to define arbitrary server side XQueries which can also be requested by HTTP and are also suitable for web applications. Both methods are not restricted to a single database.

Best regards,

  Markus

 

[1] http://docs.basex.org/wiki/REST

[2] http://docs.basex.org/wiki/RESTXQ

 

Am 21.02.2020 um 02:05 schrieb DYER Chris:

I am looking for some ideas on some architecture surrounding xquery modules.

 

Our situation is that we have multiple client applications in various languages that will connect to a database.

We will have some reasonably complex xqueries to extract data in certain structures that will be used by each of these clients.

So to avoid having to duplicate the query logic we would like the xqueries to reside "in" the database.

 

Additionally, we would like to use the same BaseX installation for multiple databases, corresponding to multiple projects.

The data in each of these databases may be against a different schema and our xqueries are essentially tied to the schema of the data. Thus, each database may need slightly different xqueries.

 

The xquery library modules looks to be global for the BaseX instance, as does the loading of main modules off of disk.

Is there any way to tie the query module or file to a specific database?

 

We are trying to avoid being limited to 1 database per BaseX instance.

 

An alternative would be to embed the xqueries within our client applications, but that involves duplication. Also, we are not sure if there are any performance difference with having the queries stored in the repo vs client side?

 

For background, we are looking at migrating from oracle to BaseX. So, we are effectively looking for an equivalent of multiple clients connecting to a userspace and using stored procedures which are specific to that userspace.

 

Any ideas on how to achieve this currently? Or is this something that BaseX could support?

 

Cheers,

Chris

 

-- 
Markus Wittenberg
 
Tel +49 (0)341 248 475 36
Mail wittenberg@axxepta.de
 
----
 
axxepta solutions GmbH
Lehmgrubenweg 17, 88131 Lindau
 
Amtsgericht Berlin HRB 97544B
Geschäftsführer: Karsten Becke, Maximilian Gärber
-- 
Markus Wittenberg
 
Tel +49 (0)341 248 475 36
Mail wittenberg@axxepta.de
 
----
 
axxepta solutions GmbH
Lehmgrubenweg 17, 88131 Lindau
 
Amtsgericht Berlin HRB 97544B
Geschäftsführer: Karsten Becke, Maximilian Gärber