function tripal_example_schema

2.x tripal_example.install tripal_example_schema()

Implementation of hook_schema().

Provides a list of tables to be created inside of the Drupal schema (the 'public' schema by default). It uses the Drupal Schema API array structure to define the table, its indexes and constraints.

Schema API documentation is here: https://api.drupal.org/api/drupal/includes%21database%21schema.inc/group...

File

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

Code

function tripal_example_schema() {

  // EXPLANATION: If your module creates a node type for data in the Chado
  // database then you probably need to link Drupal nodes with a respective ID
  // in the Chado table. The following is an example array for a table that will
  // link the 'chado_example' node type (created by this example module) with a
  // record in the fake Chado example table. This table will link the 'nid' of
  // the node with the 'example_id' of the example record.
  $schema['chado_example'] = array(
    'fields' => array(
      'vid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0
      ),
      'nid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0
      ),
      'example_id' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0
      ),
      'sync_date' => array(
        'type' => 'int',
        'not null' => FALSE,
        'description' => 'UNIX integer sync date/time'
      ),
    ),
    'indexes' => array(
      'chado_example_idx1' => array('example_id')
    ),
    'unique keys' => array(
      'chado_example_uq1' => array('nid', 'vid'),
      'chado_example_uq2' => array('vid')
    ),
    'primary key' => array('nid'),
  );

  return $schema;
}