Can't create foreign key using SCHEMA API I am trying to create 2 tables, linked together, using this code:

$schema['parent'] = array(
    "fields" =&gt; array(
        "id" =&gt; array(
            'description' =&gt; 'The primary identifier',
            'type' =&gt; 'serial',
            'unsigned' =&gt; TRUE,
            'not null' =&gt; TRUE,
        ),
        'data' =&gt; array(
            'description' =&gt; 'The stored data.',
            'type' =&gt; 'varchar',
            'length' =&gt; 255,
            'not null' =&gt; TRUE,
            'default' =&gt; '',
        ),
    ),
    'primary key' =&gt; array('id'),
);

$schema['child'] = array(
    // {{{fields

    "fields" =&gt; array(
        "id" =&gt; array(
            'description' =&gt; 'The primary identifier',
            'type' =&gt; 'serial',
            'unsigned' =&gt; TRUE,
            'not null' =&gt; TRUE,
        ),
        "parent_id" =&gt; array(
            'type' =&gt; 'int',
            'unsigned' =&gt; TRUE,
        ),
        'data' =&gt; array(
            'description' =&gt; 'The stored data.',
            'type' =&gt; 'varchar',
            'length' =&gt; 255,
            'not null' =&gt; TRUE,
            'default' =&gt; '',
        ),
    ),
    // }}}
    'indexes' =&gt; array(
        "parent_id" =&gt; array("parent_id"),
    ),
    'foreign keys' =&gt; array(
        'parent_id' =&gt; array(
            'table' =&gt; 'parent',
            'columns' =&gt; array('id' =&gt; 'parent_id'),
        ),
    ),
    'primary key' =&gt; array('id'),
);

foreach ($schema as $key =&gt; $value) {
    print $key . "\n";
    db_create_table($key, $value);
}


The tables are created, but the foreign keys are not. Using MySQL/InnoDB. How to fix it?

Also how to set ON DELETE CASCADE and ON UPDATE CASCADE?
Schema Reference


  Foreign key definitions were added in Drupal 7 for documentation
  purposes only, and do not modify the database.