You are here

function ad_schema in Advertisement 6

Same name and namespace in other branches
  1. 6.3 ad.install \ad_schema()
  2. 6.2 ad.install \ad_schema()
  3. 7.3 ad.install \ad_schema()
  4. 7 ad.install \ad_schema()
  5. 7.2 ad.install \ad_schema()

Ad module database schema.

File

./ad.install, line 14
Advertisement module database schema.

Code

function ad_schema() {

  /**
   * The ad table stores administrative information about each ad.  The
   * actual ad itself can be found in the appropriate ad type table.
   */
  $schema['ads'] = array(
    'description' => 'The ad table stores administrative information about each ad.  The actual ad itself can be found in the appropriate ad type table.',
    'fields' => array(
      'aid' => array(
        'type' => 'int',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'default' => 0,
        'description' => 'Unique ad ID. Equals to ad nid.',
      ),
      'uid' => array(
        'type' => 'int',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'default' => 0,
        'description' => 'The {users}.uid that owns this node; initially, this is the user that created it.',
      ),
      'adstatus' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Ad status',
      ),
      'adtype' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Ad type',
      ),
      'redirect' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Ad redirect URL',
      ),
      'autoactivate' => array(
        'type' => 'int',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'default' => 0,
        'description' => 'Is ad autoactivating?',
      ),
      'autoactivated' => array(
        'type' => 'int',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'default' => 0,
        'description' => 'Is ad autoactivated?',
      ),
      'autoexpire' => array(
        'type' => 'int',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'default' => 0,
        'description' => 'Is ad autoexpiring?',
      ),
      'autoexpired' => array(
        'type' => 'int',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'default' => 0,
        'description' => 'Is ad autoexpired?',
      ),
      'activated' => array(
        'type' => 'int',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'default' => 0,
        'description' => 'Is ad activated?',
      ),
      'maxviews' => array(
        'type' => 'int',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'default' => 0,
        'description' => 'Maximum ad impressions',
      ),
      'maxclicks' => array(
        'type' => 'int',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'default' => 0,
        'description' => 'Maximum ad clicks',
      ),
      'expired' => array(
        'type' => 'int',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'default' => 0,
        'description' => 'Is ad expired?',
      ),
    ),
    'primary key' => array(
      'aid',
    ),
    'indexes' => array(
      'uid' => array(
        'uid',
      ),
      'autoactivate' => array(
        'autoactivate',
      ),
      'autoactivate' => array(
        'autoactivate',
      ),
    ),
  );

  /**
   * This table counts each time a given action occurs on an ad.  Actions
   * include when the ad is viewed, clicked, enabled and disabled.
   * Statistics are collected at an hourly granularity.
   *
   * The source column is used for tracking statistics for externally
   * hosted ads.
   *
   * Actions:
   *  'view', 'click', 'enable', 'disable'
   */
  $schema['ad_statistics'] = array(
    'description' => 'Stores ad statistics.',
    'fields' => array(
      'sid' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'description' => 'Statistics entry ID.',
      ),
      'aid' => array(
        'type' => 'int',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'default' => 0,
        'description' => 'Ad id.',
      ),
      'date' => array(
        'type' => 'int',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'default' => 0,
        'description' => 'Date when action was made.',
      ),
      'action' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Actions: "view", "click", "enable", "disable".',
      ),
      'adgroup' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
        'default' => '',
        'description' => 'Ad group.',
      ),
      'hostid' => array(
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Host from which acion was made.',
      ),
      'count' => array(
        'type' => 'int',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'default' => 0,
        'description' => 'Count of actions triggered.',
      ),
    ),
    'primary key' => array(
      'sid',
    ),
    'indexes' => array(
      'aid' => array(
        'aid',
      ),
      'date' => array(
        'date',
      ),
      'action' => array(
        'action',
      ),
      'adgroup' => array(
        'adgroup',
      ),
      'hostid' => array(
        'hostid',
      ),
    ),
  );

  /**
   * The ad_clicks table tracks when a given advertisement was clicked,
   * who clicked it (uid if any and IP address), and what page they were
   * on when they clicked it.
   */
  $schema['ad_clicks'] = array(
    'description' => 'The ad_clicks table tracks when a given advertisement was clicked, who clicked it (uid if any and IP address), and what page they were on when they clicked it.',
    'fields' => array(
      'cid' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'description' => 'Statistics entry ID.',
      ),
      'aid' => array(
        'type' => 'int',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'default' => 0,
        'description' => 'Ad id.',
      ),
      'uid' => array(
        'type' => 'int',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'default' => 0,
        'description' => '',
      ),
      'status' => array(
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'default' => 0,
        'description' => '',
      ),
      'hostname' => array(
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Host from which acion was made.',
      ),
      'user_agent' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Clicker\'s browser agent.',
      ),
      'adgroup' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Ad group.',
      ),
      'hostid' => array(
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Host from which acion was made.',
      ),
      'url' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
        'default' => '',
        'description' => 'Clicked URL.',
      ),
      'timestamp' => array(
        'type' => 'int',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'default' => 0,
        'description' => 'Date when action was made.',
      ),
    ),
    'primary key' => array(
      'cid',
    ),
    'indexes' => array(
      'aid' => array(
        'aid',
      ),
      'status' => array(
        'status',
      ),
      'hostname' => array(
        'hostname',
      ),
      'user_agent' => array(
        'user_agent',
      ),
      'adgroup' => array(
        'adgroup',
      ),
      'hostid' => array(
        'hostid',
      ),
      'url' => array(
        'url',
      ),
    ),
  );

  /**
   * The ad_hosts table is used to configure users that can display ads
   * remotely.
   */
  $schema['ad_hosts'] = array(
    'description' => 'The ad_hosts table is used to configure users that can display ads remotely. ',
    'fields' => array(
      'uid' => array(
        'type' => 'int',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'default' => 0,
        'description' => '',
      ),
      'hostid' => array(
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Host from which acion was made.',
      ),
      'status' => array(
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'default' => 0,
        'description' => '',
      ),
      'description' => array(
        'type' => 'text',
        'not null' => FALSE,
        'description' => 'Host from which acion was made.',
      ),
    ),
    'primary key' => array(
      'uid',
    ),
    'indexes' => array(
      'status' => array(
        'status',
      ),
      'hostid' => array(
        'hostid',
      ),
    ),
  );
  return $schema;
}