Same name and namespace in other branches
  1. 8.x-1.x dbtng_example/dbtng_example.install \dbtng_example_schema()

Implements hook_schema().

Defines the database tables used by this module. Remember that the easiest way to create the code for hook_schema is with the schema module

See also

hook_schema()

Related topics

File

dbtng_example/dbtng_example.install, line 55
Install, update and uninstall functions for the dbtng_example module.

Code

function dbtng_example_schema() {
  $schema['dbtng_example'] = array(
    'description' => 'Stores example person entries for demonstration purposes.',
    'fields' => array(
      'pid' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'description' => 'Primary Key: Unique person ID.',
      ),
      'uid' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => "Creator user's {users}.uid",
      ),
      'name' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Name of the person.',
      ),
      'surname' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Surname of the person.',
      ),
      'age' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
        'description' => 'The age of the person in years.',
      ),
    ),
    'primary key' => array(
      'pid',
    ),
    'indexes' => array(
      'name' => array(
        'name',
      ),
      'surname' => array(
        'surname',
      ),
      'age' => array(
        'age',
      ),
    ),
  );
  return $schema;
}