function tripal_cv_add_cv_root_mview
2.x tripal_cv.install | tripal_cv_add_cv_root_mview() |
Add a materialized view of root terms for all chado cvs. This is needed for viewing cv trees
Related topics
1 call to tripal_cv_add_cv_root_mview()
- tripal_cv_install in tripal_cv/
tripal_cv.install - Implementation of hook_install().
File
- tripal_cv/
tripal_cv.install, line 193 - Contains functions executed only on install/uninstall of this module
Code
function tripal_cv_add_cv_root_mview() {
$mv_name = 'cv_root_mview';
$comment = 'A list of the root terms for all controlled vocabularies. This is needed for viewing CV trees';
$schema = array(
'table' => $mv_name,
'description' => $comment,
'fields' => array(
'name' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
),
'cvterm_id' => array(
'size' => 'big',
'type' => 'int',
'not null' => TRUE,
),
'cv_id' => array(
'size' => 'big',
'type' => 'int',
'not null' => TRUE,
),
'cv_name' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
),
),
'indexes' => array(
'cv_root_mview_indx1' => array('cvterm_id'),
'cv_root_mview_indx2' => array('cv_id'),
),
);
$sql = "
SELECT DISTINCT CVT.name,CVT.cvterm_id, CV.cv_id, CV.name
FROM cvterm_relationship CVTR
INNER JOIN cvterm CVT on CVTR.object_id = CVT.cvterm_id
INNER JOIN cv CV on CV.cv_id = CVT.cv_id
WHERE CVTR.object_id not in
(SELECT subject_id FROM cvterm_relationship)
";
// Create the MView
tripal_add_mview($mv_name, 'tripal_cv', $schema, $sql, $comment);
}