Link Orphans

From IMSMA Wiki
Jump to navigation Jump to search

All Actions (New, Replace, Combine, Save, Approve, Unlink, etc.) creates different types of rows and different number of rows in the table link. Orphans indicate that the data has been deleted with SQL but not all rows.

Case Items linking to Location orphans

The items that was approved to these Locations do not exist in the database anymore. The Locations that have the orphans opens without any error messages so I do not think these orphans must be deleted from the database.

SELECT
"public".link.approval_state,
"public".link.from_guid,
"public".link.from_link_type,
"public".link.to_link_type,
"public"."location".location_localid,
"public"."location".locationname,
"public".gazetteer.gazetteername,
"public".gazetteerlevel."level",
"public".link.system_link,
"public".link.to_link_is_version,
"public".link.update_type,
"public".link.data_entry_date,
"public".link.data_enterer
FROM
"public".link
INNER JOIN "public"."location" ON "public".link.to_guid = "public"."location".location_guid
INNER JOIN "public".gazetteer ON "public"."location".gazetteer_guid = "public".gazetteer.gazetteer_guid
INNER JOIN "public".gazetteerlevel ON "public".gazetteer.gazlevel_guid = "public".gazetteerlevel.gazlevel_guid
WHERE
"public".link.from_guid IS NULL
ORDER BY
"public"."location".location_localid ASC

Case Items linking to other than Location orphans

The items that was approved to these items do not exist in the database anymore. The items that have the orphans opens without any error messages so I do not think these orphans must be deleted from the database.

SELECT
"public".link.approval_state,
"public".link.from_guid,
"public".link.from_link_type,
"public".link.to_link_type,
"public".link.system_link,
"public".link.to_link_is_version,
"public".link.data_entry_date,
"public".link.update_type
FROM
"public".link
WHERE
"public".link.from_guid IS NULL AND
"public".link.to_link_type <> 'LOCATION'

Template:NavBox Hub