function dbtng_example_schema

Same name and namespace in other branches
  1. 7.x-1.x dbtng_example/dbtng_example.install \dbtng_example_schema()
  2. 4.0.x modules/dbtng_example/dbtng_example.install \dbtng_example_schema()

Implements hook_schema().

Defines the database tables used by this module.

See also

hook_schema()

Related topics

File

modules/dbtng_example/dbtng_example.install, line 48

Code

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