From 6ef9aac9a17519094289ea027122e708ce53513e Mon Sep 17 00:00:00 2001 From: inghamn Date: Tue, 26 Jan 2010 18:43:21 +0000 Subject: [PATCH] Sections are now stored in a seperate table, with forign keys from the Intements git-svn-id: https://rosehill.googlecode.com/svn/trunk@54 100bd78a-fc82-11de-b5bc-ffd2847a4b57 --- scripts/migration/import.sql | 22 ++++++++++++---------- scripts/mysql.sql | 3 ++- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/scripts/migration/import.sql b/scripts/migration/import.sql index 5faaa1c..0b1f04a 100644 --- a/scripts/migration/import.sql +++ b/scripts/migration/import.sql @@ -2,16 +2,6 @@ insert cemeteries set id=1,name='White Oak'; insert cemeteries set id=2,name='Rose Hill'; -insert deeds (id,section,lot,lastname1,firstname1,middleInitial1, - lastname2,firstname2,middleInitial2,issueDate,notes,lot2,cemetery_id) -select r.ID,r.SEC,r.LOT,r.LNAME1,r.FNAME1,r.MI1, - r.LNAME2,r.FNAME2,r.MI2,r.DATE_ISSUE,r.NOTES,r.lot2,c.id -from rosehill.DEED r -left join cemeteries c on r.whiteoak=substr(c.name,1,1); - - -update rosehill.ROSEHILL set WHITEOAK='R' where WHITEOAK is null; - insert sections (code,cemetery_id) select distinct SEC,1 from rosehill.ROSEHILL where WHITEOAK='W' and SEC is not null; @@ -19,6 +9,8 @@ insert sections (code,cemetery_id) select distinct SEC,2 from rosehill.ROSEHILL where WHITEOAK='R' and SEC is not null; + + insert interments(id,section_id,lot,book,pageNumber,deceasedDate, lastname,firstname,middleInitial, birthPlace,lastResidence,age,sex,cemetery_id,notes,lot2) @@ -28,3 +20,13 @@ select r.ID,s.id,r.LOT,r.BOOK,r.PAGENUM,r.DEATH, from rosehill.ROSEHILL r left join cemeteries c on r.WHITEOAK=substr(c.name,1,1) left join sections s on r.SEC=s.code and c.id=s.cemetery_id; + + + +insert deeds (id,section_id,lot,lastname1,firstname1,middleInitial1, + lastname2,firstname2,middleInitial2,issueDate,notes,lot2,cemetery_id) +select r.ID,s.id,r.LOT,r.LNAME1,r.FNAME1,r.MI1, + r.LNAME2,r.FNAME2,r.MI2,r.DATE_ISSUE,r.NOTES,r.lot2,c.id +from rosehill.DEED r +left join cemeteries c on r.whiteoak=substr(c.name,1,1) +left join sections s on r.SEC=s.code and c.id=s.cemetery_id; diff --git a/scripts/mysql.sql b/scripts/mysql.sql index b9d8a10..e39843c 100644 --- a/scripts/mysql.sql +++ b/scripts/mysql.sql @@ -48,7 +48,7 @@ create table sections ( create table deeds ( id int unsigned not null primary key auto_increment, - section varchar(5), + section_id int unsigned, lot varchar(5), lastname1 varchar(20), firstname1 varchar(20), @@ -60,6 +60,7 @@ create table deeds ( notes text, lot2 char(5), cemetery_id int unsigned, + foreign key (section_id) references sections(id), foreign key (cemetery_id) references cemeteries(id) ) engine=InnoDB;