Mainly, added the dwellings table, implied by the revised ERD.

Some other tidy up.
This commit is contained in:
Simon Brooke 2018-05-26 19:23:21 +01:00
parent 162274c23f
commit f86c5cffe6
8 changed files with 1258 additions and 274 deletions

View file

@ -0,0 +1,8 @@
alter table electors
add column address_id references addresses on delete no action;
update electors
set address_id =
(select address_id
from dwellings
where dwellings.id electors.dwelling_id);

View file

@ -0,0 +1,11 @@
CREATE TABLE dwellings
(
id INT NOT NULL PRIMARY KEY,
address_id INT NOT NULL references addresses on delete no action,
sub_address VARCHAR( 32)
);
alter table electors
add column dwelling_id int references dwellings on delete no action;
alter table electors drop column address_id;