oVirt 3.1 ERD

Database structure and dependencies


Where do I define my db connection?

in JBoss 7.x the database configuration is defined in $JBOSS_HOME/standalone/configuration/standalone.xml

              `               ` `                   ``jdbc:postgresql://localhost:5432/ovirt` `                   ``postgresql` `                   ``TRANSACTION_READ_COMMITTED` `                   ` `                       ``1` `                       ``100` `                       ``true` `                   ` `                   ` `                       ``postgres` `                   ` `                   ` `                       ``100` `                   ` `               ` `               ` `                   ` `                       ``org.postgresql.xa.PGXADataSource` `                   ` `               ` `           `

Database objects

All database objects are defined under the dbscripts directory


All table definitions are defined in create_tables.sql script This includes only the baseline of the database while each addition to this structure is done via an upgrade script.


The create_tables.sql script includes also constrains definitions of 3 types

   Primary keys
   Foreign keys
   Default value for a column
   Value validation


Generally, postgres implies an index on the table PK Apart of that this file has also some secondary index definitions to boost related queries Since our application is mostly for read operations, adding an index does not affect the application performance


All table definitions are defined in create_views.sql script Any modification to a view is done directly on this file.

Stored Procedures

All application store procedure definitions are defined in files that match the *_sp.sql pattern Any modification to a those files is done directly in the relevant file.

Helper functions

Helper functions are defined in common_sp.sql script and have the fn_db_ prefix Those functions are mostly used in upgrade scripts (explained later on) Application general functions are defined in create_functions.sql Script helper functions are defined in dbfunctions.sh and dbcustomfunctions.sh

Some of those stored procedure implement horizonal/vertical filter according to the user that is accessing the database. Example:

   Create or replace FUNCTION GetVdsByVdsId(v_vds_id UUID, v_user_id UUID, v_is_filtered BOOLEAN) RETURNS SETOF vds
    AS $procedure$
    v_columns text[];
       if (v_is_filtered) then
           FROM fn_db_mask_object('vds') as q (rec vds)
           WHERE (rec).vds_id = v_vds_id
           AND EXISTS (SELECT 1
               FROM   user_vds_permissions_view
               WHERE  user_id = v_user_id AND entity_id = v_vds_id);
           FROM vds
           WHERE vds_id = v_vds_id;
       end if;
   END; $procedure$