function tripal_example_add_example_relationship_table

2.x tripal_example.install tripal_example_add_example_relationship_table()

Adds the 'example_relationship' custom table to Chado.

1 call to tripal_example_add_example_relationship_table()
tripal_example_add_custom_tables in tripal_example/tripal_example.install
Add custom tables to Chado that are required by this module

File

tripal_example/tripal_example.install, line 425
Installation of the example module

Code

function tripal_example_add_example_relationship_table() {
  // EXPLANATION: use the Drupal Schema API to describe the custom table. Then
  // add the table using the chado_create_custom_table() function.

  $schema = array(
    'table' => 'example_relationship',
    'fields' => array(
      'example_relationship_id' => array(
        'type' => 'serial',
        'not null' => TRUE,
      ),
      'subject_id' => array(
        'type' => 'int',
        'not null' => TRUE,
      ),
      'object_id' => array(
        'type' => 'int',
        'not null' => TRUE,
      ),
      'type_id' => array(
        'type' => 'int',
        'not null' => TRUE,
      ),
      'value' => array(
        'type' => 'text',
        'not null' => FALSE,
      ),
      'rank' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      0 => 'example_relationship_id',
    ),
    'unique keys' => array(
      'example_relationship_c1' => array(
        0 => 'subject_id',
        1 => 'object_id',
        2 => 'type_id',
        3 => 'rank',
      ),
    ),
    'indexes' => array(
      'example_relationship_idx1' => array(
        0 => 'subject_id',
      ),
      'example_relationship_idx2' => array(
        0 => 'object_id',
      ),
      'example_relationship_idx3' => array(
        0 => 'type_id',
      ),
    ),
    'foreign keys' => array(
      'cvterm' => array(
        'table' => 'cvterm',
        'columns' => array(
          'type_id' => 'cvterm_id',
        ),
      ),
      'example' => array(
        'table' => 'example',
        'columns' => array(
          'subject_id' => 'example_id',
          'object_id' => 'example_id',
        ),
      ),
    ),
  );
  chado_create_custom_table('example_relationship', $schema, TRUE);
}