function analytics_schema in Analytics 6
Same name and namespace in other branches
- 7 analytics.install \analytics_schema()
Implementation of hook_schema().
File
- ./
analytics.install, line 6
Code
function analytics_schema() {
$schema = array();
$schema['analytics_events'] = array(
'description' => 'A list of all recorded analytics events.',
'fields' => array(
'id' => array(
'description' => 'Event ID, used to join against {analytics_property_instance}.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'event_name' => array(
'description' => 'Text representation of the event.',
'type' => 'varchar',
'length' => '255',
'not null' => FALSE,
),
),
'primary key' => array(
'id',
),
'indexes' => array(
'event_name' => array(
'event_name',
),
),
);
$schema['analytics_properties'] = array(
'description' => 'A list of all properties belong to all events.',
'fields' => array(
'id' => array(
'description' => 'The property ID, user to join against {analytics_property_instance}.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'property_name' => array(
'description' => 'Text representation of the property.',
'type' => 'varchar',
'length' => '255',
'not null' => FALSE,
),
),
'primary key' => array(
'id',
),
'indexes' => array(
'property_name' => array(
'property_name',
),
),
);
$schema['analytics_property_instance'] = array(
'description' => 'This table stores relation between analytics events, and analytics properties.',
'fields' => array(
'id' => array(
'description' => 'Property instance ID, used to join against {analytics_property_values}.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'event_id' => array(
'description' => 'Event ID, used to join against {analytics_events}.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'property_id' => array(
'description' => 'Property ID, used to join against {analytics_properties}.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array(
'id',
),
'indexes' => array(
'event_id' => array(
'event_id',
),
'property_id' => array(
'property_id',
),
),
);
$schema['analytics_property_values'] = array(
'description' => 'Storage for event properties',
'fields' => array(
'id' => array(
'description' => 'Property storage ID.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'property_id' => array(
'description' => 'Property ID, used to join aganst {analytics_properties}.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'event_instance_id' => array(
'description' => 'Property ID, used to join aganst {analytics_properties}.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'value' => array(
'description' => 'The value for this property, ',
'type' => 'varchar',
'length' => '255',
'not null' => FALSE,
),
),
'primary key' => array(
'id',
),
'indexes' => array(
'property_id' => array(
'property_id',
),
'event_instance_id' => array(
'event_instance_id',
),
'value' => array(
'value',
),
),
);
$schema['analytics_event_instance'] = array(
'description' => 'Storage for events',
'fields' => array(
'id' => array(
'description' => 'Event instance ID.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'event_id' => array(
'description' => 'Event ID, used to join aganst {analytics_events}.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'date' => array(
'description' => 'Date of this event.',
'type' => 'datetime',
'not null' => TRUE,
),
'year' => array(
'description' => 'Year of the event.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'month' => array(
'description' => 'Month of the event.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'week' => array(
'description' => 'Week of the event.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'ip' => array(
'description' => 'IP address associated with this event.',
'type' => 'varchar',
'length' => '255',
'not null' => TRUE,
),
'unique_id' => array(
'description' => 'A unique ID associated with this event.',
'type' => 'varchar',
'length' => '255',
'not null' => FALSE,
),
),
'primary key' => array(
'id',
),
'indexes' => array(
'event_id' => array(
'event_id',
),
'date' => array(
'date',
),
'month' => array(
'month',
),
'week' => array(
'week',
),
'year' => array(
'year',
),
'ip' => array(
'ip',
),
),
);
return $schema;
}