← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3337: Added sql integrity checks

 

------------------------------------------------------------
revno: 3337
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2011-04-11 13:10:49 +0200
message:
  Added sql integrity checks
modified:
  resources/sql/integritychecks.sql


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'resources/sql/integritychecks.sql'
--- resources/sql/integritychecks.sql	2011-03-18 12:55:58 +0000
+++ resources/sql/integritychecks.sql	2011-04-11 11:10:49 +0000
@@ -54,8 +54,38 @@
 
 -- Recreate indexes on aggregated tables
 
-DROP INDEX aggregateddatavalue_index;
-DROP INDEX aggregatedindicatorvalue_index;
-CREATE INDEX aggregateddatavalue_index ON aggregateddatavalue (dataelementid, categoryoptioncomboid, periodid, organisationunitid);
-CREATE INDEX aggregatedindicatorvalue_index ON aggregatedindicatorvalue (indicatorid, periodid, organisationunitid);
+drop index aggregateddatavalue_index;
+drop index aggregatedindicatorvalue_index;
+drop index aggregateddatasetcompleteness_index;
+create index aggregateddatavalue_index on aggregateddatavalue (dataelementid, categoryoptioncomboid, periodid, organisationunitid);
+create index aggregatedindicatorvalue_index on aggregatedindicatorvalue (indicatorid, periodid, organisationunitid);
+create index aggregateddatasetcompleteness_index on aggregateddatasetcompleteness  (datasetid, periodid, organisationunitid);
+
+-- Get category option combos without category options
+
+select * from categoryoptioncombo where categoryoptioncomboid not in (select distinct categoryoptioncomboid from categoryoptioncombos_categoryoptions);
+
+-- Get category option combos without category combo
+
+select * from categoryoptioncombo where categoryoptioncomboid not in (select distinct categoryoptioncomboid from categorycombos_optioncombos);
+
+-- Get category options without category option combos
+
+select * from dataelementcategoryoption where categoryoptionid not in (select distinct categoryoptionid from categoryoptioncombos_categoryoptions);
+
+-- Get catetegory options without categories
+
+select * from dataelementcategoryoption where categoryoptionid not in (select distinct categoryoptionid from categories_categoryoptions);
+
+-- Get categories without category options
+
+select * from dataelementcategory where categoryid not in (select distinct categoryid from categories_categoryoptions);
+
+-- Get categories without category combos
+
+select * from dataelementcategory where categoryid not in (select distinct categoryid from categorycombos_categories);
+
+-- Get category combos without categories
+
+select * from categorycombo where categorycomboid not in (select distinct categorycomboid from categorycombos_categories);