header

Accessing preexisting databases in AMGA

It is possible to access previously existing databases through AMGA. This is done by importing them into AMGA's information schema. The importation will just create links to the imported table, and does not copy the table.

The first step is to configure an Access through ODBC to your existing database. Please follow the instructions for UnixODBC or tools like Tora for this.

The next step is to install the AMGA server on a system with direct access to the backend network. You will need to add the AMGA support tables to the existing database by applying the suitable createInitial.sql script for your database, you can find in the config directory of the source distribution or in PREFIX/share/doc of the binary distributions. Should there be clashes of the namespace, you can try to solve them using different schema names, provided your RDBMS supports this.

Once this has been achieved, set up the amgad server to point to your database (see Configuring the AMGA Server and the Replicatin Daemon). Then connect the client using the AMGA root-user (see Configuration of the C++ and Java command line clients) and start importing the tables using the import tablename dir command (see Metadata Access from the Shell). This will make the table with the given tablename known to AMGA as the name given in the "dir" option. You can set access permissions to the new table via the chmod/chown commands or via the ACL system. You can also now use AMGA to alter the table-schema.

After reconnecting as an ordinary user, you can start using the imported tables. Since they do not have the supporting information normal AMGA tables have, only the standard SQL functionality works, namely insertion of entries, selecting (including joins to other tables) and updating and deleting. The ls-command is (currently) not supported.

The follwoing is an example using a PostgreSQL database in which we create a simple table called test.

$ psql -U arda metadata
Welcome to psql 8.1.8, the PostgreSQL interactive terminal.
metadata=> CREATE TABLE test(item integer, name varchar(256));
CREATE TABLE
metadata=> INSERT INTO test (item, name) VALUES (1, 'apple');
INSERT 0 1
metadata=> INSERT INTO test (item, name) VALUES (2, 'pear');
INSERT 0 1

Setting the user to "root" in mdclient.config, we can connect to the AMGA server to import the generated table:

$ mdclient 
Connecting to localhost:8822...
ARDA Metadata Server 1.2.10
Query> whoami
>> root
Query> import test  /atest  plain:main=item
Query> ls -ld /atest
>> rwxrwxr-x root                                  /atest
Query> addattr /atest i int
Query> listattr /atest
>> item
>> int
>> name
>> varchar(256)
>> i
>> int
Query> quit

As shown, it is possible to investigate the table schema, and even alter it.

Now edit mdclient.config so that you log in as an ordinary user, and you can use the imported table:

Query> selectattr /atest:name /atest:item ''
>> apple
>> 1
>> pear
>> 2
Query> selectattr /atest:name /atest:item '/atest:item=2'
>> pear
>> 2
Query> rm /atest 'item=2'
Error: 4: Permission denied.
As you can see, AMGA has protected the table using it's access control mechanisms.

When you import tables, AMGA allows you to use options to describe which properties the table has. AMGA will assume that the table has the following properties, which must be present in a way that AMGA can understand and use them, that is they must be implemented in the standard way AMGA does: shared: The table can be later shared by other directories created "under" it.


Generated on Mon Apr 16 13:59:18 2012 for AMGA by  doxygen 1.4.7