J S-R and KE are setting up a site with the netlink urbanst, which requires a db. I've got that set up, so we're ready to go. We're meeting on Wednesday to get started.
Leaving early.
Following a meeting with JW, made a range of changes to the db:
- Added a new select field and associated table for "status".
- Added a new select field and associated table for "grouping".
- Replaced the "approaches" tables with "themes" tables (same data, but new table and field names).
- Renamed the "notes" column to "synopsis".
- Added a new one-to-many field and two associated tables for "language".
- Added four new comments fields, one each for these one-to-many fields: document type, language, theme, and authorship.
- Updated the local_classes.php and the copy_live_to_dev_db.sql files to support all the changes.
This is the SQL:
# Create the status table
CREATE TABLE IF NOT EXISTS `status` (
`st_id` int(11) NOT NULL auto_increment,
`st_name` varchar(128) collate utf8_unicode_ci default NULL,
PRIMARY KEY (`st_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1;
# Add a record to it
INSERT INTO `status` (st_name) VALUES ("active");
# Add the field that links to it
ALTER TABLE `revolt` ADD COLUMN `rv_status` INT(11) AFTER `rv_id`;
# Add the constraint.
ALTER TABLE `revolt`
ADD CONSTRAINT `revolt_ibfk_4` FOREIGN KEY (`rv_status`) REFERENCES `status` (`st_id`) ON DELETE SET NULL ON UPDATE CASCADE;
# Create a new themes table based on the existing approaches table
CREATE TABLE IF NOT EXISTS `theme` (
`th_id` int(11) NOT NULL auto_increment,
`th_name` varchar(128) collate utf8_unicode_ci default NULL,
PRIMARY KEY (`th_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=9 ;
# Copy the data into it.
INSERT INTO `theme` (`th_id`, `th_name`) SELECT `ap_id`, `ap_name` FROM `approach`;
# Create a new theme_to_revolt table based on the existing approach_to_revolt table
CREATE TABLE IF NOT EXISTS `theme_to_revolt` (
`thr_thr_id` int(11) NOT NULL auto_increment,
`thr_th_id_fk` int(11) NOT NULL,
`thr_rv_id_fk` int(11) NOT NULL,
PRIMARY KEY (`thr_thr_id`),
KEY `thr_th_id_fk` (`thr_th_id_fk`),
KEY `thr_rv_id_fk` (`thr_rv_id_fk`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=132 ;
# Copy the data over to the new table
INSERT INTO `theme_to_revolt` (`thr_thr_id`, `thr_th_id_fk`, `thr_rv_id_fk`) SELECT `apr_apr_id`, `apr_ap_id_fk`, `apr_rv_id_fk` FROM `approach_to_revolt`;
#Rename the notes field to synopsis
ALTER TABLE `revolt` CHANGE `rv_notes` `rv_synopsis` longtext collate utf8_unicode_ci;
#Add three new columns
ALTER TABLE `revolt` ADD `rv_themeComments` varchar(2048) collate utf8_unicode_ci default NULL;
ALTER TABLE `revolt` ADD `rv_docTypeComments` varchar(2048) collate utf8_unicode_ci default NULL;
ALTER TABLE `revolt` ADD `rv_authorshipComments` varchar(2048) collate utf8_unicode_ci default NULL;
# Create the language table
CREATE TABLE IF NOT EXISTS `lang` (
`ln_id` int(11) NOT NULL auto_increment,
`ln_name` varchar(128) collate utf8_unicode_ci default NULL,
PRIMARY KEY (`ln_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1;
# Add a record to it
INSERT INTO `lang` (ln_name) VALUES ("English");
# Create the linking table.
# Create a new theme_to_revolt table based on the existing approach_to_revolt table
CREATE TABLE IF NOT EXISTS `lang_to_revolt` (
`lnr_lnr_id` int(11) NOT NULL auto_increment,
`lnr_ln_id_fk` int(11) NOT NULL,
`lnr_rv_id_fk` int(11) NOT NULL,
PRIMARY KEY (`lnr_lnr_id`),
KEY `lnr_ln_id_fk` (`lnr_ln_id_fk`),
KEY `lnr_rv_id_fk` (`lnr_rv_id_fk`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1;
# Add the constraints
ALTER TABLE `lang_to_revolt`
ADD CONSTRAINT `lang_to_revolt_ibfk_1` FOREIGN KEY (`lnr_rv_id_fk`) REFERENCES `revolt` (`rv_id`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `lang_to_revolt_ibfk_2` FOREIGN KEY (`lnr_ln_id_fk`) REFERENCES `lang` (`ln_id`) ON DELETE CASCADE ON UPDATE CASCADE;
#Add new language comment column
ALTER TABLE `revolt` ADD `rv_langComments` varchar(2048) collate utf8_unicode_ci default NULL;
# Create new grouping table
CREATE TABLE IF NOT EXISTS `grouping` (
`gr_id` int(11) NOT NULL auto_increment,
`gr_name` varchar(128) collate utf8_unicode_ci default NULL,
PRIMARY KEY (`gr_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1;
# Add a record to it
INSERT INTO `grouping` (gr_name) VALUES ("[none]");
# Add the field that links to it
ALTER TABLE `revolt` ADD COLUMN `rv_grouping` INT(11) AFTER `rv_region`;
# Add the constraint.
ALTER TABLE `revolt`
ADD CONSTRAINT `revolt_ibfk_5` FOREIGN KEY (`rv_grouping`) REFERENCES `grouping` (`gr_id`) ON DELETE SET NULL ON UPDATE CASCADE;
#Drop the tables we no longer need.
DROP TABLE `approach_to_revolt`;
DROP TABLE `approach`;
Now that I have the data in a usable XML format (an example record is below), I need to plan the process by which SQL statements are generated and sequenced in order to add it to the database. There are a number of key issues that need to be carefully handled:
- Insertions will be made into the following tables:
- Properties
- Titles (the core table)
- Owners
- Lenders
- Mortgages
- Other documents
- The insertions will have to be made in such a way that links can be established between related records. For this reason, each record has a unique id, and each mortgage does too (because mortgages and lenders will have to be linked).
- Because there are lots of one-to-many relationships, and also because many of the items such as owners and lenders being added will be duplicates of existing ones, we need to stage the insertions carefully.
This is the proposed sequence:
- First, add a temporary "tracking" field to each of the tables we're using. This will be used to store a list of ids to which the record is linked, so we can create links later on.
- For each record:
- Handle its property information:
- Check for an existing record with the same property information as this one. If it exists, add the record id to its tracking field (followed by a space). If it doesn't, create it, and add the id.
- Create its title record (we assume that these titles don't yet exist in the database). Place the record id in its tracking field.
- Create the owners. For each owner:
- Check for an existing owner with the same display name, street number and street name. If it exists, add the record id to its tracking field. If it doesn't exist, create it, and place the record id in its tracking field.
- Create the mortgages. For each mortgage:
- Create a new mortgage record (we assume that mortgages are unique to titles, and therefore unique in the db). Store the mortgage id in its tracking field.
- Create the lenders. For each lender:
- Check for an existing lender with the same display name, street number and street name. If it exists, add the mortgage id to its tracking field. If it doesn't exist, create it, and place the mortgage id in its tracking field.
- Handle the "other documents". For each document:
- Check for an existing record with the same document number. If it exists, add the record id to its tracking field; if not, create it, and place the record id in its tracking field.
- Handle its property information:
- Create the links. For each title with an id in its tracking field (meaning we've just added it), get its ttl_title_id, and:
- Get the first record in the property table which has the record's tracking id in its tracking field (there should only be one), and set the title record's ttl_property_id_fk field to its prp_property_id.
- For each owner which has the same id in its tracking field, get its own_owner_id, and create a new record in the owners_to_titles table.
- For each mortgage which has the record id as the middle part of its tracking id:
- Get its mgg_mortgage_id.
- Create a new record in the mortgages_to_titles table.
- For each lender which has the mortgage's tracking id in its tracking field:
- Get its lnd_lender_id.
- Create a record in the lenders_to_mortgages table.
- For each record in the other_docs table which has the record's id in its tracking field, get its odc_doc_id and create a record in the docs_to_titles table.
- Empty all the tracking fields. We may as well keep them, in case they're useful in future.
<record gen-id="d1e30029" orig-id="5701075"> <property> <district>196</district> <plan>196</plan> <block>70</block> <lot>2</lot> <census-tract>57.01</census-tract> </property> <title> <title-code>J68726L</title-code> <traces/> <t1-doc-lots>1, 2 and 3</t1-doc-lots> <traces>H9471L,H9472L, na, na, na, na, na, na, na, na, na, na</traces> <date>1981-09-02</date> <ownership-split>Shek Holdings Co. Ltd. (Incorporation no. 241563): 7/10 A. Youngson Investments Ltd (Incorporation no. 240974): 3/10</ownership-split> <notes/> </title> <owners> <owner> <name>Shek Holdings Co. Ltd. (Incorporation no. 241563)</name> <occupation/> <street-num>539</street-num> <street>Main St</street> <city/> <province/> <post-code/> <undivided-interest>7/10</undivided-interest> </owner> <owner> <name>A. Youngson Investments Ltd (Incorporation no. 240974)</name> <occupation/> <street-num>940</street-num> <street>West King Edward Ave</street> <city>n</city> <province/> <post-code/> <undivided-interest>3/10</undivided-interest> </owner> </owners> <mortgages> <mortgage gen-id="mort_d1e30029_d1e30236"> <doc-num>M H6566</doc-num> <year/> <cancelled>n</cancelled> <cancelled-date/> <value/> <modified/> <modified-date/> <modified-by/> <term-date/> <interest/> <remarks>Lots 1 and 2</remarks> <lenders> <lender>The Imperial Life Assurance Company of Canada</lender> </lenders> </mortgage> <mortgage gen-id="mort_d1e30029_d1e30263"> <doc-num>M H7796</doc-num> <year>1980</year> <cancelled>y</cancelled> <cancelled-date>1981</cancelled-date> <value/> <modified/> <modified-date/> <modified-by/> <term-date/> <interest/> <remarks>Lots 1 and 2</remarks> <lenders> <lender>Canadian Imperial Bank of Commerce</lender> </lenders> </mortgage> <mortgage gen-id="mort_d1e30029_d1e30295"> <doc-num>M H45708</doc-num> <year>1980</year> <cancelled>y</cancelled> <cancelled-date>1981</cancelled-date> <value/> <modified/> <modified-date/> <modified-by/> <term-date/> <interest/> <remarks>Lots 1 and 2</remarks> <lenders> <lender>Canadian Imperial Bank of Commerce</lender> </lenders> </mortgage> </mortgages> <other-docs> <doc> <doc-num>AR H6567</doc-num> <year>1980</year> <parties>The Imperial Life Assurance Company of Canada</parties> <remarks>Lots 1 and 2</remarks> </doc> </other-docs> </record>
I've always been unhappy with the way original and modern transcriptions in the engravings are stored in separate annotations and linked to separate zones. I think a better approach would be to combine the two within one annotation, inside special divs that mark them as alternates:
<div type="transcription_alternates">
<div type="transcription_orig">
<p>[...]</p>
</div>
<div type="transcription_modern">
<p>[...]</p>
</div>
</div>
The XSLT could then provide a single pop-up annotation window with a choice of two tabs at the top or the bottom, so you could switch between them. It could even remember your preference (the last tab you looked at) in a cookie.
It might be possible to automate the conversion of the existing code to this new approach using XSLT; you'd have to identify zones which were equivalent (mostly overlapping), and rewrite the contents of the Transcription category so it contains both, then delete the modernized ones. I think this would definitely be a cleaner approach to providing both transcriptions.
More research on the regularizations suggests that those which handle i/j and u/v variation are also unnecessary in the original transcription field. Using this XQuery, I was able to identify 573 choice elements which have 340 distinct variants:
xquery version "1.0"; declare default element namespace "http://www.tei-c.org/ns/1.0"; let $list := ( for $c in //choice[orig] where translate($c/orig, 'sſuvUVijIJ', '') = translate($c/reg, 'sſuvUVijIJ', '') return concat($c/orig, ' : ', $c/reg) ), $distList := distinct-values($list) return (concat(count($list), ' items, of which there are ', count($distList), ' distinct values: '), $distList)
If CC agrees that all these are irrelevant, it would be easy to remove them. That would leave 247 other regularizations, which mainly seem to consist of supplying missing spacing and apostrophes. These could presumably be kept.
I discovered when validating documents that some had information missing from their headers (part of the Image Markup Tool header info, perhaps dating back to a version of the IMT that didn't handle that data properly under Wine on Linux). Fixed those, and also fixed some errors in il_cherche.xml, which had one annotation that was classed as an Objet but actually contained transcription.