<?php
// $Id: kwresearch.install,v 1.1.2.11 2010/09/26 00:36:49 tomdude48 Exp $

/**
 * @file
 * Install hooks for Keyword Research.
 */

/**
 *  Implementation of hook_install().
 */
function kwresearch_install() {
  drupal_install_schema('kwresearch');
  drupal_set_message(t('Keyword Research has been installed.')); 
}

/**
 * Implementation of hook_uninstall().
 */
function kwresearch_uninstall() {
  drupal_uninstall_schema('kwresearch');
  drupal_set_message(t('Keyword Research has been uninstalled.'));  
}

/**
 *  Implementation of hook_schema
 */
function kwresearch_schema() {

  $schema['kwresearch_keyword'] = array(
    'description' => 'Creates database table to store keyword data.',
    'fields' => array(
      'kid' => array(
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'description' => 'The id for the keyword.',  
      ), //kid
      'uid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => FALSE,
        'description' => 'The id for the user.',  
      ), //uid
      'keyword' => array(
        'type' => 'varchar',
        'length' => '255',
        'not null' => TRUE,
        'default' => '',
        'description' => 'subject keyword.',  
      ), //keyword  
      'word_count' => array(
        'type' => 'int',
        'size' => 'tiny',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 1,
        'description' => 'number of words in phrase',  
      ), //word_count  
      'priority' => array(
        'type' => 'int',
        'size' => 'tiny',
        //'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => -1,
        'description' => 'importance of word to site',  
      ), //priority  
      'value' => array(
        'type' => 'float',
        //'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => -1,
        'description' => 'value of word to site',  
      ), //value 
      'page_count' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => 'number of pages with keyword assocated',  
      ), //page_count
      'stats_update' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => FALSE,
        'description' => 'timestamp of last data update',  
      ), //stats_update
      'daily_volume' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => FALSE,
        'description' => 'estimated times the keyword is searched on major search engines per day',  
      ), //daily_volume
      'bid' => array(
        'type' => 'float',
        //'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => -1,
        'description' => 'recommended bid price for keyword phrase',  
      ), //value 
      'competition' => array(
        'type' => 'int',
        'size' => 'tiny',
        //'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => -1,
        'description' => 'level of competition for the keyword phrase',  
      ), //competitiveness
    
    ),
    'primary key' => array('kid'),
    'indexes' => array(
      'keyword' => array('keyword'),
      'priority' => array('priority'),
    ),
  );
  $schema['kwresearch_page_keyword'] = array(
    'description' => 'Creates database table to store page keyword data.',
    'fields' => array(
      'kid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'description' => 'The id for the keyword.',  
      ), //kid
      'nid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => FALSE,
        'description' => 'The id for the node.',  
      ), //nid
      'path' => array(
        'type' => 'varchar',
        'length' => '255',
        'not null' => FALSE,
        'description' => 'path to page.',  
      ), //path  
      'uid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => FALSE,
        'description' => 'The id for the user.',  
      ), //uid
      'priority' => array(
        'type' => 'int',
        'size' => 'tiny',
        //'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => -1,
        'description' => 'importance of word to site',  
      ), //priority  

    ),
    'indexes' => array(
      'kid' => array('kid'),
      'nid' => array('nid'),
      'path' => array('path'),
    ),
  );
  $schema['kwresearch_wordtracker_data'] = array(
    'description' => 'Creates database table to store wordtracker data.',
    'fields' => array(
      'keyphrase' => array(
        'type' => 'varchar',
        'length' => '255',
        'not null' => TRUE,
        'default' => '',
        'description' => 'target keyphrase.',  
      ), //keyphrase   
      'include_misspellings' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 1,
        'description' => t('flag if misspellings should be included.'),  
      ), //include_misspellings   
      'include_plurals' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 1,
        'description' => t('flag if plurals should be included.'),  
      ), //include_plurals 
      'adult_filter' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 1,
        'description' => t('adult filter option.'),  
      ), //adult_filter 
      'all_words_popularity' => array(
        'type' => 'text',
        'description' => t('result from all_words_popularity api call'),  
      ), //all_words_popularity 
      'all_words_popularity_limit' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => t('number of results returned in api call.'),  
      ), //all_words_popularity_limit  
      'exact_phrase_popularity' => array(
        'type' => 'text',
        'description' => t('result from exact_phrase_popularity api call'),  
      ), //exact_phrase_popularity 
      'exact_phrase_popularity_limit' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => t('number of results returned in api call.'),  
      ), //exact_phrase_popularity_limit  
      'embedded_phrase_popularity' => array(
        'type' => 'text',
        'description' => t('result from embedded_phrase_popularity api call'),  
      ), //embedded_phrase_popularity 
      'embedded_phrase_popularity_limit' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => t('number of results returned in api call.'),  
      ), //embedded_phrase_popularity_limit 

      'lateral_keyphrases' => array(
        'type' => 'text',
        'description' => t('result from lateral_keyphrases api call'),  
      ), //lateral_keyphrases
      'lateral_keyphrases_max' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => t('number of results returned in api call.'),  
      ), //lateral_keyphrases_max  

      'thesaurus_keyphrases' => array(
        'type' => 'text',
        'description' => t('result from thesaurus_keyphrases api call'),  
      ), //thesaurus_keyphrases
      'thesaurus_keyphrases_depth' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => t('number of results returned in api call.'),  
      ), //thesaurus_keyphrases_depth   
    ),
    'primary key' => array('keyphrase', 'include_misspellings', 'include_plurals', 'adult_filter'),
  ); 
  return $schema;
}