function recommender_schema in Recommender API 7.6
Same name and namespace in other branches
- 5 recommender.install \recommender_schema()
- 6.3 recommender.install \recommender_schema()
- 6 recommender.install \recommender_schema()
- 6.2 recommender.install \recommender_schema()
- 7.3 recommender.install \recommender_schema()
- 7.4 recommender.install \recommender_schema()
- 7.5 recommender.install \recommender_schema()
Implements hook_schema(). Helper modules should use drupal_get_unprocessed_schema() to create tables for their own.
File
- ./
recommender.install, line 12 - Installation file for the Recommender API module.
Code
function recommender_schema() {
$schema = array(
// table to save preference scores
'recommender_preference' => array(
'description' => 'This is the main table to save preference data. The structure is similar to prediction/similarity table.',
'fields' => array(
// this id might be redundant.
'id' => array(
'description' => 'Unique index for each preference data',
'type' => 'serial',
'size' => 'normal',
'unsigned' => TRUE,
'not null' => TRUE,
),
'uid' => array(
'description' => 'User ID',
'type' => 'int',
'size' => 'normal',
'unsigned' => TRUE,
'not null' => TRUE,
),
'eid' => array(
'description' => 'Entity ID',
'type' => 'int',
'size' => 'normal',
'unsigned' => TRUE,
'not null' => TRUE,
),
'score' => array(
'type' => 'float',
'size' => 'normal',
'not null' => FALSE,
'description' => 'The preference score. Higher score means the user prefers the item more.',
),
'updated' => array(
'description' => 'The Unix timestamp a record is last changed',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array(
'id',
),
// 'foreign keys' => array(
// 'uid' => array(
// 'table' => 'users',
// 'columns' => array('uid' => 'uid'),
// ),
// ),
'indexes' => array(
'uid_eid' => array(
'uid',
'eid',
),
),
),
// table to save user similarity scores
'recommender_user_similarity' => array(
'description' => 'This is the main table to save user similarity data.',
'fields' => array(
// this id might be redundant.
'id' => array(
'description' => 'Unique index for each similarity pair',
'type' => 'serial',
'size' => 'normal',
'unsigned' => TRUE,
'not null' => TRUE,
),
'uid1' => array(
'description' => 'The first user ID',
'type' => 'int',
'size' => 'normal',
'unsigned' => TRUE,
'not null' => TRUE,
),
'uid2' => array(
'description' => 'The second user ID',
'type' => 'int',
'size' => 'normal',
'unsigned' => TRUE,
'not null' => TRUE,
),
'score' => array(
'type' => 'float',
'size' => 'normal',
'not null' => FALSE,
'description' => 'Similarity score. The bigger, the more similar',
),
'updated' => array(
'description' => 'The Unix timestamp this similarity is last changed',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array(
'id',
),
// 'foreign keys' => array(
// 'uid1' => array(
// 'table' => 'users',
// 'columns' => array('uid1' => 'uid'),
// ),
// 'uid2' => array(
// 'table' => 'users',
// 'columns' => array('uid1' => 'uid'),
// ),
// ),
'indexes' => array(
'uid1_uid2' => array(
'uid1',
'uid2',
),
),
),
// table to save item similarity scores
'recommender_item_similarity' => array(
'description' => 'This is the main table to save item similarity data.',
'fields' => array(
// this id might be redundant.
'id' => array(
'description' => 'Unique index for each similarity pair',
'type' => 'serial',
'size' => 'normal',
'unsigned' => TRUE,
'not null' => TRUE,
),
'eid1' => array(
'description' => 'The first entity ID',
'type' => 'int',
'size' => 'normal',
'unsigned' => TRUE,
'not null' => TRUE,
),
'eid2' => array(
'description' => 'The second entity ID',
'type' => 'int',
'size' => 'normal',
'unsigned' => TRUE,
'not null' => TRUE,
),
'score' => array(
'type' => 'float',
'size' => 'normal',
'not null' => FALSE,
'description' => 'Similarity score. The bigger, the more similar',
),
'updated' => array(
'description' => 'The Unix timestamp this similarity is last changed',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array(
'id',
),
'indexes' => array(
'eid1_eid2' => array(
'eid1',
'eid2',
),
),
),
// table to save prediction data
'recommender_prediction' => array(
'description' => 'This is the main table to save prediction data.',
'fields' => array(
// this id might be redundant.
'id' => array(
'description' => 'Unique index for each prediction link',
'type' => 'serial',
'size' => 'normal',
'unsigned' => TRUE,
'not null' => TRUE,
),
'uid' => array(
'description' => 'User id',
'type' => 'int',
'size' => 'normal',
'unsigned' => TRUE,
'not null' => TRUE,
),
'eid' => array(
'description' => 'Entity ID',
'type' => 'int',
'size' => 'normal',
'unsigned' => TRUE,
'not null' => TRUE,
),
'score' => array(
'type' => 'float',
'size' => 'normal',
'not null' => FALSE,
'description' => 'The prediction score. Higher score means the user prefers the item more.',
),
'updated' => array(
'description' => 'The Unix timestamp this prediction is last changed',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array(
'id',
),
// 'foreign keys' => array(
// 'uid' => array(
// 'table' => 'users',
// 'columns' => array('uid' => 'uid'),
// ),
// ),
'indexes' => array(
'uid_eid' => array(
'uid',
'eid',
),
),
),
);
return $schema;
}