-- The first part of this SQL-script is to check CERA tables for any _id whithout target.
--   It must not return any rows but those with _id=0.
--   (this script is to be run to ensure DB integrity).                             FT 14.12.98
spool checkAll
select     *                   from SUMMARY           where summary_id           not in 
   (select summary_id           from ENTRY             where summary_id           is not NULL);
select *                       from QUALITY           where quality_id           not in 
   (select quality_id           from ENTRY             where quality_id           is not NULL);
select *                       from SPATIAL_COVERAGE  where spatial_coverage_id  not in 
   (select  spatial_coverage_id from COVERAGE          where spatial_coverage_id  is not NULL);
select *                       from TEMPORAL_COVERAGE where temporal_coverage_id not in 
   (select temporal_coverage_id from COVERAGE          where temporal_coverage_id is not NULL);
select *                       from DATA_ACCESS       where data_access_id       not in 
   (select data_access_id       from PARAMETER         where data_access_id       is not NULL);
--
-- The second part checks for entries not linked to the important CERA Blocks
--   PARAMETER, COVERAGE, DISTRIBUTION. It should not return any rows.              FT 14.12.98
select *                       from ENTRY             where entry_id             not in
   (select entry_id             from PARAMETER         where entry_id             is not NULL);
select *                       from ENTRY             where entry_id             not in
   (select entry_id             from COVERAGE          where entry_id             is not NULL);
select *                       from ENTRY             where entry_id             not in
   (select entry_id             from DISTRIBUTION      where entry_id             is not NULL);
spool off
