At a high level, there are three types of change found within COU:
Deletes (CHANGE_TYPE ‘D’) are objects that have ceased to exist in the product since the last product refresh.
Inserts (CHANGE_TYPE ‘I’) are objects that have been newly inserted into the product since the last product refresh.
Updates (CHANGE_TYPE ‘U’) are objects that have been updated in the product since the last product refresh.
High-level COU implementation model
High-level COU implementation model diagram
High-level COU implementation model with archiving
Before a COU is applied, there may be a business requirement to archive existing address records. The diagram below shows how to implement archiving with an AddressBase Core COU within a database.
High-level COU implementation model with archiving diagram
Applying COU to tables
Within AddressBase Core there will be no records with the same UPRN. You can test this by checking the number of records that have the same UPRN. The following SQL query notifies you of any duplicates.
This query should return 0 rows, and this confirms that there are no duplicates. As there are no duplicate records, we can use the UPRN to apply the COU.
With archiving
Where there is a business requirement to keep the records that are being Updated and Deleted in a separate archive table, the following SQL will create an Archive Table. It will populate with records that are being Updated and Deleted from the live AddressBase Core table.
The following commands create an archive table of the records that are being updated and deleted from the existing table, for example, addressbase_core_archive.
SELECT uprn, COUNT(uprn) AS NumOccurrences FROM <table_name>
GROUP BY uprn
HAVING ( COUNT(uprn) > 1 );
CREATE TABLE <abcore_archive_table_name> AS SELECT * FROM <master_abcore_table_name> WHERE uprn IN (SELECT uprn FROM <abcore_cou_table_name> WHERE change_code != 'I');
DELETE FROM <master_abcore_table_name>
WHERE uprn IN (SELECT uprn FROM <abcore_cou_table_name> WHERE change_code != 'I');
INSERT INTO <master_abcore_table_name>
SELECT * FROM <abcore_cou_table_name> WHERE change_code != 'D';
DELETE FROM <master_abcore_table_name>
WHERE uprn IN (SELECT uprn FROM <abcore_cou_table_name> WHERE change_code != 'I');
INSERT INTO <master_abcore_table_name>
SELECT * FROM <abcore_cou_table_name> WHERE change_code != 'D';