## GnomeDbDatabase

GnomeDbDatabase — Represents a database in the DBMS server

##

# Synopsis

    struct      GnomeDbDatabase;
    GType       gnome_db_database_get_type      (void);
    GObject*    gnome_db_database_new           (GnomeDbDict *dict);
    GnomeDbDict* gnome_db_database_get_dict     (GnomeDbDatabase *mgdb);
    gboolean    gnome_db_database_update_dbms_data
                                                (GnomeDbDatabase *mgdb,
                                                 GError **error);
    void        gnome_db_database_stop_update_dbms_data
                                                (GnomeDbDatabase *mgdb);
    GSList*     gnome_db_database_get_tables    (GnomeDbDatabase *mgdb);
    GnomeDbTable* gnome_db_database_get_table_by_name
                                                (GnomeDbDatabase *mgdb,
                                                 const gchar *name);
    GnomeDbTable* gnome_db_database_get_table_by_xml_id
                                                (GnomeDbDatabase *mgdb,
                                                 const gchar *xml_id);
    GnomeDbField* gnome_db_database_get_field_by_name
                                                (GnomeDbDatabase *mgdb,
                                                 const gchar *fullname);
    GnomeDbField* gnome_db_database_get_field_by_xml_id
                                                (GnomeDbDatabase *mgdb,
                                                 const gchar *xml_id);
    GnomeDbSequence* gnome_db_database_get_sequence_by_name
                                                (GnomeDbDatabase *mgdb,
                                                 const gchar *name);
    GnomeDbSequence* gnome_db_database_get_sequence_by_xml_id
                                                (GnomeDbDatabase *mgdb,
                                                 const gchar *xml_id);
    GnomeDbSequence* gnome_db_database_get_sequence_to_field
                                                (GnomeDbDatabase *mgdb,
                                                 GnomeDbField *field);
    void        gnome_db_database_link_sequence (GnomeDbDatabase *mgdb,
                                                 GnomeDbSequence *seq,
                                                 GnomeDbField *field);
    void        gnome_db_database_unlink_sequence
                                                (GnomeDbDatabase *mgdb,
                                                 GnomeDbSequence *seq,
                                                 GnomeDbField *field);
    void        gnome_db_database_add_constraint
                                                (GnomeDbDatabase *mgdb,
                                                 GnomeDbConstraint *cstr);
    GSList*     gnome_db_database_get_all_constraints
                                                (GnomeDbDatabase *mgdb);
    GSList*     gnome_db_database_get_all_fk_constraints
                                                (GnomeDbDatabase *mgdb);
    GSList*     gnome_db_database_get_table_constraints
                                                (GnomeDbDatabase *mgdb,
                                                 GnomeDbTable *table);
    GSList*     gnome_db_database_get_tables_fk_constraints
                                                (GnomeDbDatabase *mgdb,
                                                 GnomeDbTable *table1,
                                                 GnomeDbTable *table2,
                                                 gboolean table1_has_fk);

## Object Hierarchy

      GObject
       +----GnomeDbBase
             +----GnomeDbDatabase

## Implemented Interfaces

GnomeDbDatabase implements GnomeDbXmlStorage.

## Properties

      "prop"                 gpointer             : Read / Write

## Signal Prototypes

    "constraint-added"
                void        user_function      (GnomeDbDatabase *dbdatabase,
                                                gpointer arg1,
                                                gpointer user_data);
    "constraint-removed"
                void        user_function      (GnomeDbDatabase *dbdatabase,
                                                gpointer arg1,
                                                gpointer user_data);
    "constraint-updated"
                void        user_function      (GnomeDbDatabase *dbdatabase,
                                                gpointer arg1,
                                                gpointer user_data);
    "data-update-finished"
                void        user_function      (GnomeDbDatabase *dbdatabase,
                                                gpointer user_data);
    "data-update-started"
                void        user_function      (GnomeDbDatabase *dbdatabase,
                                                gpointer user_data);
    "field-added"
                void        user_function      (GnomeDbDatabase *dbdatabase,
                                                gpointer arg1,
                                                gpointer user_data);
    "field-removed"
                void        user_function      (GnomeDbDatabase *dbdatabase,
                                                gpointer arg1,
                                                gpointer user_data);
    "field-updated"
                void        user_function      (GnomeDbDatabase *dbdatabase,
                                                gpointer arg1,
                                                gpointer user_data);
    "fs-link-added"
                void        user_function      (GnomeDbDatabase *dbdatabase,
                                                gpointer arg1,
                                                gpointer arg2,
                                                gpointer user_data);
    "fs-link-removed"
                void        user_function      (GnomeDbDatabase *dbdatabase,
                                                gpointer arg1,
                                                gpointer arg2,
                                                gpointer user_data);
    "sequence-added"
                void        user_function      (GnomeDbDatabase *dbdatabase,
                                                gpointer arg1,
                                                gpointer user_data);
    "sequence-removed"
                void        user_function      (GnomeDbDatabase *dbdatabase,
                                                gpointer arg1,
                                                gpointer user_data);
    "sequence-updated"
                void        user_function      (GnomeDbDatabase *dbdatabase,
                                                gpointer arg1,
                                                gpointer user_data);
    "table-added"
                void        user_function      (GnomeDbDatabase *dbdatabase,
                                                gpointer arg1,
                                                gpointer user_data);
    "table-removed"
                void        user_function      (GnomeDbDatabase *dbdatabase,
                                                gpointer arg1,
                                                gpointer user_data);
    "table-updated"
                void        user_function      (GnomeDbDatabase *dbdatabase,
                                                gpointer arg1,
                                                gpointer user_data);
    "update-progress"
                void        user_function      (GnomeDbDatabase *dbdatabase,
                                                gpointer arg1,
                                                guint arg2,
                                                guint arg3,
                                                gpointer user_data);

## Description

This object manages an internal dictionary mirroring the real database structure with objects such as GnomeDbTable (composed of GnomeDbfield objects) and GnomeDbConstraint.

Implements the GnomeDbXmlStorage interface.

## Details

### struct GnomeDbDatabase

    struct GnomeDbDatabase;

### gnome_db_database_get_type ()

    GType       gnome_db_database_get_type      (void);

Returns : | the type id

### gnome_db_database_new ()

    GObject*    gnome_db_database_new           (GnomeDbDict *dict);

Creates a new GnomeDbDatabase object

`dict` : | a GnomeDbDict object
Returns : | the new object

### gnome_db_database_get_dict ()

    GnomeDbDict* gnome_db_database_get_dict     (GnomeDbDatabase *mgdb);

Fetch the GnomeDbDict object to which the GnomeDbDatabase belongs.

`mgdb` : | a GnomeDbDatabase object
Returns : | the GnomeDbDict object

### gnome_db_database_update_dbms_data ()

    gboolean    gnome_db_database_update_dbms_data
                                                (GnomeDbDatabase *mgdb,
                                                 GError **error);

Synchronises the Table representation with the table structure which is stored in the DBMS. For this operation to succeed, the connection to the DBMS server MUST be opened (using the corresponding GnomeDbServer object).

`mgdb` : |
`error` : | location to store error, or `NULL`
Returns : | TRUE if no error

### gnome_db_database_stop_update_dbms_data ()

    void        gnome_db_database_stop_update_dbms_data
                                                (GnomeDbDatabase *mgdb);

When the database updates its internal lists of DBMS objects, a call to this function will stop that update process. It has no effect when the database is not updating its DBMS data.

`mgdb` : | a GnomeDbDatabase object

### gnome_db_database_get_tables ()

    GSList*     gnome_db_database_get_tables    (GnomeDbDatabase *mgdb);

Get a list of all the tables within `mgdb`

`mgdb` : | a GnomeDbDatabase object
Returns : | a new list of all the GnomeDbTable objects

### gnome_db_database_get_table_by_name ()

    GnomeDbTable* gnome_db_database_get_table_by_name
                                                (GnomeDbDatabase *mgdb,
                                                 const gchar *name);

Get a reference to a GnomeDbTable using its name.

`mgdb` : | a GnomeDbDatabase object
`name` : | the name of the requested table
Returns : | The GnomeDbTable pointer or NULL if the requested table does not exist.

### gnome_db_database_get_table_by_xml_id ()

    GnomeDbTable* gnome_db_database_get_table_by_xml_id
                                                (GnomeDbDatabase *mgdb,
                                                 const gchar *xml_id);

Get a reference to a GnomeDbTable using its XML id.

`mgdb` : | a GnomeDbDatabase object
`xml_id` : | the XML id of the requested table
Returns : | The GnomeDbTable pointer or NULL if the requested table does not exist.

### gnome_db_database_get_field_by_name ()

    GnomeDbField* gnome_db_database_get_field_by_name
                                                (GnomeDbDatabase *mgdb,
                                                 const gchar *fullname);

Get a reference to a GnomeDbField specifying the full name (table_name.field_name) of the requested field.

`mgdb` : | a GnomeDbDatabase object
`fullname` : | the name of the requested table field
Returns : | The GnomeDbField pointer or NULL if the requested field does not exist.

### gnome_db_database_get_field_by_xml_id ()

    GnomeDbField* gnome_db_database_get_field_by_xml_id
                                                (GnomeDbDatabase *mgdb,
                                                 const gchar *xml_id);

Get a reference to a GnomeDbField specifying its XML id

`mgdb` : | a GnomeDbDatabase object
`xml_id` : | the XML id of the requested table field
Returns : | The GnomeDbField pointer or NULL if the requested field does not exist.

### gnome_db_database_get_sequence_by_name ()

    GnomeDbSequence* gnome_db_database_get_sequence_by_name
                                                (GnomeDbDatabase *mgdb,
                                                 const gchar *name);

Get a reference to a GnomeDbSequence specifying its name

`mgdb` : | a GnomeDbDatabase object
`name` : | the name of the requested sequence
Returns : | The GnomeDbSequence pointer or NULL if the requested sequence does not exist.

### gnome_db_database_get_sequence_by_xml_id ()

    GnomeDbSequence* gnome_db_database_get_sequence_by_xml_id
                                                (GnomeDbDatabase *mgdb,
                                                 const gchar *xml_id);

Get a reference to a GnomeDbSequence specifying its XML id.

`mgdb` : | a GnomeDbDatabase object
`xml_id` : | the XML id of the requested sequence
Returns : | The GnomeDbSequence pointer or NULL if the requested sequence does not exist.

### gnome_db_database_get_sequence_to_field ()

    GnomeDbSequence* gnome_db_database_get_sequence_to_field
                                                (GnomeDbDatabase *mgdb,
                                                 GnomeDbField *field);

Get a reference to a GnomeDbSequence which is "linked" to the GnomeDbField given as parameter. This "link" means that each new value of the field will be given by the returned sequence

`mgdb` : | a GnomeDbDatabase object
`field` : | a GnomeDbField object
Returns : | The GnomeDbSequence pointer or NULL if there is no sequence for this job.

### gnome_db_database_link_sequence ()

    void        gnome_db_database_link_sequence (GnomeDbDatabase *mgdb,
                                                 GnomeDbSequence *seq,
                                                 GnomeDbField *field);

Tells the database that each new value of the field given as argument should be obtained from the specified sequence (this is usefull when the field is a simple primary key for example).

`mgdb` : | a GnomeDbDatabase object
`seq` : |
`field` : |

### gnome_db_database_unlink_sequence ()

    void        gnome_db_database_unlink_sequence
                                                (GnomeDbDatabase *mgdb,
                                                 GnomeDbSequence *seq,
                                                 GnomeDbField *field);

Tells the database that each new value of the field given as argument should not be obtained from the specified sequence (this is usefull when the field is a simple primary key for example). This is the opposite of the `gnome_db_database_link_sequence()` method.

`mgdb` : | a GnomeDbDatabase object
`seq` : |
`field` : |

### gnome_db_database_add_constraint ()

    void        gnome_db_database_add_constraint
                                                (GnomeDbDatabase *mgdb,
                                                 GnomeDbConstraint *cstr);

Add the `cstr` constraint to the database. The `cstr` constraint is a user-defined constraint (which is not part of the database structure itself).

`mgdb` : | a GnomeDbDatabase object
`cstr` : | a GnomeDbConstraint

### gnome_db_database_get_all_constraints ()

    GSList*     gnome_db_database_get_all_constraints
                                                (GnomeDbDatabase *mgdb);

Get a list of all the constraints applied to the database. Constraints are represented as GnomeDbConstraint objects and represent any type of constraint.

`mgdb` : | a GnomeDbDatabase object
Returns : | a new list of the constraints

### gnome_db_database_get_all_fk_constraints ()

    GSList*     gnome_db_database_get_all_fk_constraints
                                                (GnomeDbDatabase *mgdb);

Get a list of all the constraints applied to the database which represent a foreign constrains. Constraints are represented as GnomeDbConstraint objects.

`mgdb` : | a GnomeDbDatabase object
Returns : | a new list of the constraints

### gnome_db_database_get_table_constraints ()

    GSList*     gnome_db_database_get_table_constraints
                                                (GnomeDbDatabase *mgdb,
                                                 GnomeDbTable *table);

Get all the constraints applicable to `table`

`mgdb` : | a GnomeDbDatabase object
`table` : | a GnomeDbTable, part of `mgdb`
Returns : | a new GSList of GnomeDbConstraint objects

### gnome_db_database_get_tables_fk_constraints ()

    GSList*     gnome_db_database_get_tables_fk_constraints
                                                (GnomeDbDatabase *mgdb,
                                                 GnomeDbTable *table1,
                                                 GnomeDbTable *table2,
                                                 gboolean table1_has_fk);

Get a list of all the constraints applied to the database which represent a foreign key constrains, between `table1` and `table2`. If `table1` or `table2` are `NULL`, then the returned foreign key constraints are the ones between any table and `table1` or `table2`.

Constraints are represented as GnomeDbConstraint objects.

`mgdb` : | a GnomeDbDatabase object
`table1` : | a GnomeDbTable, or `NULL`
`table2` : | a GnomeDbTable, or `NULL`
`table1_has_fk` : | TRUE if the returned constraints are the one for which `table1` contains the foreign key
Returns : | a new list of the constraints

## Properties

"`prop`" (gpointer : Read / Write) |

## Signals

### The "constraint-added" signal

    void        user_function                  (GnomeDbDatabase *dbdatabase,
                                                gpointer arg1,
                                                gpointer user_data);

`dbdatabase` : | the object which received the signal.
`arg1` : |
`user_data` : | user data set when the signal handler was connected.

### The "constraint-removed" signal

    void        user_function                  (GnomeDbDatabase *dbdatabase,
                                                gpointer arg1,
                                                gpointer user_data);

`dbdatabase` : | the object which received the signal.
`arg1` : |
`user_data` : | user data set when the signal handler was connected.

### The "constraint-updated" signal

    void        user_function                  (GnomeDbDatabase *dbdatabase,
                                                gpointer arg1,
                                                gpointer user_data);

`dbdatabase` : | the object which received the signal.
`arg1` : |
`user_data` : | user data set when the signal handler was connected.

### The "data-update-finished" signal

    void        user_function                  (GnomeDbDatabase *dbdatabase,
                                                gpointer user_data);

`dbdatabase` : | the object which received the signal.
`user_data` : | user data set when the signal handler was connected.

### The "data-update-started" signal

    void        user_function                  (GnomeDbDatabase *dbdatabase,
                                                gpointer user_data);

`dbdatabase` : | the object which received the signal.
`user_data` : | user data set when the signal handler was connected.

### The "field-added" signal

    void        user_function                  (GnomeDbDatabase *dbdatabase,
                                                gpointer arg1,
                                                gpointer user_data);

`dbdatabase` : | the object which received the signal.
`arg1` : |
`user_data` : | user data set when the signal handler was connected.

### The "field-removed" signal

    void        user_function                  (GnomeDbDatabase *dbdatabase,
                                                gpointer arg1,
                                                gpointer user_data);

`dbdatabase` : | the object which received the signal.
`arg1` : |
`user_data` : | user data set when the signal handler was connected.

### The "field-updated" signal

    void        user_function                  (GnomeDbDatabase *dbdatabase,
                                                gpointer arg1,
                                                gpointer user_data);

`dbdatabase` : | the object which received the signal.
`arg1` : |
`user_data` : | user data set when the signal handler was connected.

### The "fs-link-added" signal

    void        user_function                  (GnomeDbDatabase *dbdatabase,
                                                gpointer arg1,
                                                gpointer arg2,
                                                gpointer user_data);

`dbdatabase` : | the object which received the signal.
`arg1` : |
`arg2` : |
`user_data` : | user data set when the signal handler was connected.

### The "fs-link-removed" signal

    void        user_function                  (GnomeDbDatabase *dbdatabase,
                                                gpointer arg1,
                                                gpointer arg2,
                                                gpointer user_data);

`dbdatabase` : | the object which received the signal.
`arg1` : |
`arg2` : |
`user_data` : | user data set when the signal handler was connected.

### The "sequence-added" signal

    void        user_function                  (GnomeDbDatabase *dbdatabase,
                                                gpointer arg1,
                                                gpointer user_data);

`dbdatabase` : | the object which received the signal.
`arg1` : |
`user_data` : | user data set when the signal handler was connected.

### The "sequence-removed" signal

    void        user_function                  (GnomeDbDatabase *dbdatabase,
                                                gpointer arg1,
                                                gpointer user_data);

`dbdatabase` : | the object which received the signal.
`arg1` : |
`user_data` : | user data set when the signal handler was connected.

### The "sequence-updated" signal

    void        user_function                  (GnomeDbDatabase *dbdatabase,
                                                gpointer arg1,
                                                gpointer user_data);

`dbdatabase` : | the object which received the signal.
`arg1` : |
`user_data` : | user data set when the signal handler was connected.

### The "table-added" signal

    void        user_function                  (GnomeDbDatabase *dbdatabase,
                                                gpointer arg1,
                                                gpointer user_data);

`dbdatabase` : | the object which received the signal.
`arg1` : |
`user_data` : | user data set when the signal handler was connected.

### The "table-removed" signal

    void        user_function                  (GnomeDbDatabase *dbdatabase,
                                                gpointer arg1,
                                                gpointer user_data);

`dbdatabase` : | the object which received the signal.
`arg1` : |
`user_data` : | user data set when the signal handler was connected.

### The "table-updated" signal

    void        user_function                  (GnomeDbDatabase *dbdatabase,
                                                gpointer arg1,
                                                gpointer user_data);

`dbdatabase` : | the object which received the signal.
`arg1` : |
`user_data` : | user data set when the signal handler was connected.

### The "update-progress" signal

    void        user_function                  (GnomeDbDatabase *dbdatabase,
                                                gpointer arg1,
                                                guint arg2,
                                                guint arg3,
                                                gpointer user_data);

`dbdatabase` : | the object which received the signal.
`arg1` : |
`arg2` : |
`arg3` : |
`user_data` : | user data set when the signal handler was connected.