Add the database schema summary, with two ER diagrams
Condenses the 96-page generated data dictionary into ten pages that can be read in one sitting: what the four schemas are for, what the table-name prefixes mean, every table with one line on what it holds, and a set of observations for the database team. The generated dictionary stays the authority on columns and types; this is the document to read first. Two diagrams carry the part the dictionary cannot show. Figure 1 is the four schemas and the fact that each of the other three has its own name for the district it refers to — district_id, district_ref, project_district_id — none of them enforced. Figure 2 is the relationships per schema, drawing the distinction that matters most: solid arrows are the nine foreign keys the database actually declares, dashed arrows are joins that exist only because two tables agree. That distinction produced three findings worth acting on, all in section 3: permit is the only schema with referential integrity, and even there comments and stages join on application_code text rather than the id; dataroom's versioning chain is held together by uuid alone; and the two enforced keys in spatial point at the legacy parcels table rather than the live lu_parcels, which is worth checking before either building table is relied on. A fourth is a loose end — zoning_districts references reference.zoning_types, a schema the dictionary does not cover at all. Diagrams are committed as SVG (editable) alongside the PNG the document embeds, following the pattern already used for the staged-upload and OpenTopography figures. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
4edb0a2f37
commit
9b4c7625d2
BIN
LUPMIS2_Database_Schema_Summary.docx
Normal file
BIN
LUPMIS2_Database_Schema_Summary.docx
Normal file
Binary file not shown.
BIN
LUPMIS2_Schema_ERM.png
Normal file
BIN
LUPMIS2_Schema_ERM.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 413 KiB |
147
LUPMIS2_Schema_ERM.svg
Normal file
147
LUPMIS2_Schema_ERM.svg
Normal file
@ -0,0 +1,147 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="1200" height="1430" viewBox="0 0 1200 1430" font-family="Calibri, Arial, sans-serif">
|
||||
<!-- Figure 2: how the tables relate, by schema.
|
||||
Solid = foreign key declared in the database.
|
||||
Dashed = tables joined on a shared value, with nothing enforcing it.
|
||||
Sized for a 5.73 in document column (~209 px/in), so 24 px ~ 8 pt. -->
|
||||
<defs>
|
||||
<marker id="s1" markerWidth="10" markerHeight="10" refX="8" refY="4" orient="auto">
|
||||
<path d="M0,0 L8,4 L0,8 Z" fill="#166534"/></marker>
|
||||
<marker id="s2" markerWidth="10" markerHeight="10" refX="8" refY="4" orient="auto">
|
||||
<path d="M0,0 L8,4 L0,8 Z" fill="#6B7280"/></marker>
|
||||
</defs>
|
||||
<rect width="1200" height="1430" fill="#FFFFFF"/>
|
||||
|
||||
<!-- legend -->
|
||||
<line x1="24" y1="26" x2="96" y2="26" stroke="#166534" stroke-width="3" marker-end="url(#s1)"/>
|
||||
<text x="110" y="34" font-size="24" fill="#333333">foreign key enforced by the database</text>
|
||||
<line x1="600" y1="26" x2="672" y2="26" stroke="#6B7280" stroke-width="2.5" stroke-dasharray="8 6" marker-end="url(#s2)"/>
|
||||
<text x="686" y="34" font-size="24" fill="#333333">joined on a shared value only</text>
|
||||
|
||||
<!-- PANEL A: permit -->
|
||||
<rect x="16" y="62" width="1168" height="430" rx="12" fill="#FAFBFF" stroke="#DCDDE9" stroke-width="2"/>
|
||||
<text x="40" y="102" font-size="30" font-weight="bold" fill="#1E1A4B">permit</text>
|
||||
<text x="140" y="102" font-size="23" fill="#6B7280">the only schema with enforced referential integrity</text>
|
||||
|
||||
<rect x="40" y="180" width="300" height="80" rx="10" fill="#EEF2FF" stroke="#1E1A4B" stroke-width="3"/>
|
||||
<text x="62" y="214" font-size="27" font-weight="bold" fill="#1E1A4B">applications</text>
|
||||
<text x="62" y="244" font-size="22" fill="#6B7280">id · application_code</text>
|
||||
|
||||
<rect x="40" y="300" width="300" height="66" rx="10" fill="#FFFFFF" stroke="#9CA3AF" stroke-width="2"/>
|
||||
<text x="62" y="330" font-size="25" fill="#333333">applicants</text>
|
||||
<text x="62" y="356" font-size="21" fill="#6B7280">applicant_id</text>
|
||||
|
||||
<rect x="40" y="396" width="300" height="66" rx="10" fill="#FFFFFF" stroke="#9CA3AF" stroke-width="2"/>
|
||||
<text x="62" y="426" font-size="25" fill="#333333">comments · stages</text>
|
||||
<text x="62" y="452" font-size="21" fill="#6B7280">application_code</text>
|
||||
|
||||
<rect x="620" y="126" width="380" height="58" rx="9" fill="#FFFFFF" stroke="#166534" stroke-width="2.5"/>
|
||||
<text x="642" y="163" font-size="25" fill="#333333">application_agents</text>
|
||||
<rect x="620" y="196" width="380" height="58" rx="9" fill="#FFFFFF" stroke="#166534" stroke-width="2.5"/>
|
||||
<text x="642" y="233" font-size="25" fill="#333333">application_consultants</text>
|
||||
<rect x="620" y="266" width="380" height="58" rx="9" fill="#FFFFFF" stroke="#166534" stroke-width="2.5"/>
|
||||
<text x="642" y="303" font-size="25" fill="#333333">application_documents</text>
|
||||
<rect x="620" y="336" width="380" height="58" rx="9" fill="#FFFFFF" stroke="#166534" stroke-width="2.5"/>
|
||||
<text x="642" y="373" font-size="25" fill="#333333">application_status_history</text>
|
||||
<rect x="620" y="406" width="380" height="58" rx="9" fill="#FFFFFF" stroke="#166534" stroke-width="2.5"/>
|
||||
<text x="642" y="443" font-size="25" fill="#333333">mining_applications</text>
|
||||
|
||||
<path d="M340 208 C 470 208, 480 155, 616 155" fill="none" stroke="#166534" stroke-width="3" marker-end="url(#s1)"/>
|
||||
<path d="M340 214 C 470 214, 480 225, 616 225" fill="none" stroke="#166534" stroke-width="3" marker-end="url(#s1)"/>
|
||||
<path d="M340 220 C 470 220, 480 295, 616 295" fill="none" stroke="#166534" stroke-width="3" marker-end="url(#s1)"/>
|
||||
<path d="M340 226 C 470 226, 480 365, 616 365" fill="none" stroke="#166534" stroke-width="3" marker-end="url(#s1)"/>
|
||||
<path d="M340 232 C 470 232, 480 435, 616 435" fill="none" stroke="#166534" stroke-width="3" marker-end="url(#s1)"/>
|
||||
|
||||
<text x="352" y="186" font-size="21" fill="#166534" stroke="#FAFBFF" stroke-width="7" paint-order="stroke" stroke-linejoin="round">application_id</text>
|
||||
|
||||
<path d="M190 300 L 190 264" fill="none" stroke="#6B7280" stroke-width="2.5" stroke-dasharray="8 6" marker-end="url(#s2)"/>
|
||||
<path d="M190 396 C 120 396, 120 300, 176 268" fill="none" stroke="#6B7280" stroke-width="2.5" stroke-dasharray="8 6" marker-end="url(#s2)"/>
|
||||
<text x="1012" y="256" font-size="22" font-weight="bold" fill="#166534">ON DELETE</text>
|
||||
<text x="1012" y="284" font-size="22" font-weight="bold" fill="#166534">CASCADE</text>
|
||||
<text x="1012" y="322" font-size="22" fill="#6B7280">deleting an</text>
|
||||
<text x="1012" y="350" font-size="22" fill="#6B7280">application</text>
|
||||
<text x="1012" y="378" font-size="22" fill="#6B7280">removes all five</text>
|
||||
|
||||
<!-- PANEL B: dataroom -->
|
||||
<rect x="16" y="512" width="1168" height="300" rx="12" fill="#FAFBFF" stroke="#DCDDE9" stroke-width="2"/>
|
||||
<text x="40" y="552" font-size="30" font-weight="bold" fill="#1E1A4B">dataroom</text>
|
||||
<text x="180" y="552" font-size="23" fill="#6B7280">a versioning chain held together by uuid alone</text>
|
||||
|
||||
<rect x="40" y="590" width="250" height="72" rx="10" fill="#EEF2FF" stroke="#1E1A4B" stroke-width="3"/>
|
||||
<text x="62" y="622" font-size="25" font-weight="bold" fill="#1E1A4B">datasets</text>
|
||||
<text x="62" y="648" font-size="21" fill="#6B7280">the catalogue entry</text>
|
||||
|
||||
<rect x="342" y="590" width="250" height="72" rx="10" fill="#FFFFFF" stroke="#9CA3AF" stroke-width="2"/>
|
||||
<text x="364" y="622" font-size="25" fill="#333333">dataset_versions</text>
|
||||
<text x="364" y="648" font-size="21" fill="#6B7280">open or finalised</text>
|
||||
|
||||
<rect x="644" y="590" width="250" height="72" rx="10" fill="#FFFFFF" stroke="#9CA3AF" stroke-width="2"/>
|
||||
<text x="666" y="622" font-size="25" fill="#333333">dataset_resources</text>
|
||||
<text x="666" y="648" font-size="21" fill="#6B7280">the files · sha256</text>
|
||||
|
||||
<rect x="946" y="590" width="238" height="72" rx="10" fill="#FFFFFF" stroke="#9CA3AF" stroke-width="2"/>
|
||||
<text x="968" y="622" font-size="25" fill="#333333">downloads</text>
|
||||
<text x="968" y="648" font-size="21" fill="#6B7280">hashed requester</text>
|
||||
|
||||
<path d="M290 626 L 338 626" stroke="#6B7280" stroke-width="2.5" stroke-dasharray="8 6" marker-end="url(#s2)"/>
|
||||
<path d="M592 626 L 640 626" stroke="#6B7280" stroke-width="2.5" stroke-dasharray="8 6" marker-end="url(#s2)"/>
|
||||
<path d="M894 626 L 942 626" stroke="#6B7280" stroke-width="2.5" stroke-dasharray="8 6" marker-end="url(#s2)"/>
|
||||
<text x="292" y="690" font-size="21" fill="#6B7280">dataset_id</text>
|
||||
<text x="594" y="690" font-size="21" fill="#6B7280">version_id</text>
|
||||
<text x="896" y="690" font-size="21" fill="#6B7280">resource_id</text>
|
||||
|
||||
<rect x="40" y="716" width="552" height="66" rx="10" fill="#FFFFFF" stroke="#9CA3AF" stroke-width="2"/>
|
||||
<text x="62" y="746" font-size="25" fill="#333333">audit_log</text>
|
||||
<text x="62" y="772" font-size="21" fill="#6B7280">status changes, by dataset and version</text>
|
||||
<text x="620" y="748" font-size="22" fill="#6B7280">datasets.current_version_id points back</text>
|
||||
<text x="620" y="776" font-size="22" fill="#6B7280">to the version being served.</text>
|
||||
|
||||
<!-- PANEL C: spatial -->
|
||||
<rect x="16" y="832" width="1168" height="580" rx="12" fill="#F7FDF9" stroke="#DCDDE9" stroke-width="2"/>
|
||||
<text x="40" y="872" font-size="30" font-weight="bold" fill="#166534">spatial</text>
|
||||
<text x="140" y="872" font-size="23" fill="#6B7280">scoped by districtid; parcels keyed by UPN</text>
|
||||
|
||||
<text x="40" y="920" font-size="23" font-weight="bold" fill="#1E1A4B">Administrative hierarchy</text>
|
||||
<rect x="40" y="936" width="238" height="62" rx="10" fill="#FFFFFF" stroke="#9CA3AF" stroke-width="2"/>
|
||||
<text x="62" y="974" font-size="24" fill="#333333">area_region</text>
|
||||
<rect x="330" y="936" width="238" height="62" rx="10" fill="#EEF2FF" stroke="#1E1A4B" stroke-width="3"/>
|
||||
<text x="352" y="974" font-size="24" font-weight="bold" fill="#1E1A4B">area_districts</text>
|
||||
<rect x="620" y="936" width="272" height="62" rx="10" fill="#FFFFFF" stroke="#9CA3AF" stroke-width="2"/>
|
||||
<text x="642" y="974" font-size="24" fill="#333333">area_collectorzones</text>
|
||||
<rect x="944" y="936" width="240" height="62" rx="10" fill="#FFFFFF" stroke="#9CA3AF" stroke-width="2"/>
|
||||
<text x="966" y="974" font-size="24" fill="#333333">area_gra</text>
|
||||
<path d="M278 967 L 326 967" stroke="#6B7280" stroke-width="2.5" stroke-dasharray="8 6" marker-end="url(#s2)"/>
|
||||
<path d="M568 967 L 616 967" stroke="#6B7280" stroke-width="2.5" stroke-dasharray="8 6" marker-end="url(#s2)"/>
|
||||
<path d="M892 967 L 940 967" stroke="#6B7280" stroke-width="2.5" stroke-dasharray="8 6" marker-end="url(#s2)"/>
|
||||
<text x="272" y="1022" font-size="21" fill="#6B7280">regionid</text>
|
||||
<text x="560" y="1022" font-size="21" fill="#6B7280">districtid</text>
|
||||
<text x="884" y="1022" font-size="21" fill="#6B7280">tscid</text>
|
||||
|
||||
<text x="40" y="1076" font-size="23" font-weight="bold" fill="#1E1A4B">Parcels — the live tables</text>
|
||||
<rect x="40" y="1092" width="250" height="62" rx="10" fill="#FFFFFF" stroke="#9CA3AF" stroke-width="2"/>
|
||||
<text x="62" y="1130" font-size="24" fill="#333333">gh_upn_grid</text>
|
||||
<rect x="342" y="1092" width="250" height="62" rx="10" fill="#EEF2FF" stroke="#1E1A4B" stroke-width="3"/>
|
||||
<text x="364" y="1130" font-size="24" font-weight="bold" fill="#1E1A4B">lu_parcels</text>
|
||||
<rect x="644" y="1092" width="250" height="62" rx="10" fill="#FFFFFF" stroke="#9CA3AF" stroke-width="2"/>
|
||||
<text x="666" y="1130" font-size="24" fill="#333333">lu_buildings</text>
|
||||
<rect x="342" y="1180" width="250" height="62" rx="10" fill="#FFFFFF" stroke="#9CA3AF" stroke-width="2"/>
|
||||
<text x="364" y="1218" font-size="24" fill="#333333">…_upload_tmp</text>
|
||||
<path d="M290 1123 L 338 1123" stroke="#6B7280" stroke-width="2.5" stroke-dasharray="8 6" marker-end="url(#s2)"/>
|
||||
<path d="M592 1123 L 640 1123" stroke="#6B7280" stroke-width="2.5" stroke-dasharray="8 6" marker-end="url(#s2)"/>
|
||||
<path d="M467 1180 L 467 1158" stroke="#6B7280" stroke-width="2.5" stroke-dasharray="8 6" marker-end="url(#s2)"/>
|
||||
<text x="252" y="1176" font-size="21" fill="#6B7280">issues upn</text>
|
||||
<text x="600" y="1176" font-size="21" fill="#6B7280">upn</text>
|
||||
<text x="612" y="1222" font-size="22" fill="#6B7280">promoted by</text>
|
||||
<text x="612" y="1248" font-size="22" fill="#6B7280">transfer_upload_to_master_json</text>
|
||||
|
||||
<text x="40" y="1300" font-size="23" font-weight="bold" fill="#1E1A4B">Legacy tables — where the only enforced keys are</text>
|
||||
<rect x="40" y="1316" width="250" height="62" rx="10" fill="#FFFFFF" stroke="#166534" stroke-width="2.5"/>
|
||||
<text x="62" y="1354" font-size="24" fill="#333333">parcels</text>
|
||||
<rect x="440" y="1316" width="250" height="62" rx="10" fill="#FFFFFF" stroke="#166534" stroke-width="2.5"/>
|
||||
<text x="462" y="1354" font-size="24" fill="#333333">buildings</text>
|
||||
<rect x="742" y="1316" width="250" height="62" rx="10" fill="#FFFFFF" stroke="#166534" stroke-width="2.5"/>
|
||||
<text x="764" y="1354" font-size="24" fill="#333333">pi_buildings</text>
|
||||
<path d="M436 1347 L 294 1347" stroke="#166534" stroke-width="3" marker-end="url(#s1)"/>
|
||||
<path d="M742 1390 C 600 1400, 320 1400, 200 1382" fill="none" stroke="#166534" stroke-width="3" marker-end="url(#s1)"/>
|
||||
<text x="300" y="1330" font-size="21" fill="#166534">parcel_id</text>
|
||||
<text x="1012" y="1354" font-size="22" fill="#6B7280">not lu_parcels</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 11 KiB |
BIN
LUPMIS2_Schema_Map.png
Normal file
BIN
LUPMIS2_Schema_Map.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 260 KiB |
61
LUPMIS2_Schema_Map.svg
Normal file
61
LUPMIS2_Schema_Map.svg
Normal file
@ -0,0 +1,61 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="1200" height="620" viewBox="0 0 1200 620" font-family="Calibri, Arial, sans-serif">
|
||||
<!-- Figure 1: the four schemas and the identifier they share.
|
||||
Sized for a 5.73 in document column (~209 px/in), so 26 px ~ 9 pt. -->
|
||||
<defs>
|
||||
<marker id="d1" markerWidth="10" markerHeight="10" refX="8" refY="4" orient="auto">
|
||||
<path d="M0,0 L8,4 L0,8 Z" fill="#6B7280"/></marker>
|
||||
</defs>
|
||||
<rect width="1200" height="620" fill="#FFFFFF"/>
|
||||
|
||||
<!-- the three record-keeping schemas -->
|
||||
<rect x="24" y="40" width="410" height="140" rx="12" fill="#F5F7FF" stroke="#1E1A4B" stroke-width="3"/>
|
||||
<text x="48" y="84" font-size="32" font-weight="bold" fill="#1E1A4B">admin</text>
|
||||
<text x="168" y="84" font-size="24" fill="#6B7280">13 tables · 28 functions</text>
|
||||
<text x="48" y="122" font-size="25" fill="#333333">Users, roles, menus, privileges,</text>
|
||||
<text x="48" y="154" font-size="25" fill="#333333">API tokens, access logging.</text>
|
||||
|
||||
<rect x="24" y="216" width="410" height="140" rx="12" fill="#F5F7FF" stroke="#1E1A4B" stroke-width="3"/>
|
||||
<text x="48" y="260" font-size="32" font-weight="bold" fill="#1E1A4B">dataroom</text>
|
||||
<text x="212" y="260" font-size="24" fill="#6B7280">5 tables · 18 functions</text>
|
||||
<text x="48" y="298" font-size="25" fill="#333333">Published datasets, versions,</text>
|
||||
<text x="48" y="330" font-size="25" fill="#333333">licensing, download tracking.</text>
|
||||
|
||||
<rect x="24" y="392" width="410" height="140" rx="12" fill="#F5F7FF" stroke="#1E1A4B" stroke-width="3"/>
|
||||
<text x="48" y="436" font-size="32" font-weight="bold" fill="#1E1A4B">permit</text>
|
||||
<text x="168" y="436" font-size="24" fill="#6B7280">10 tables · 43 functions</text>
|
||||
<text x="48" y="474" font-size="25" fill="#333333">Development and mining permit</text>
|
||||
<text x="48" y="506" font-size="25" fill="#333333">applications and documents.</text>
|
||||
|
||||
<!-- spatial -->
|
||||
<rect x="676" y="40" width="500" height="492" rx="12" fill="#F0FDF4" stroke="#166534" stroke-width="3"/>
|
||||
<text x="704" y="84" font-size="32" font-weight="bold" fill="#166534">spatial</text>
|
||||
<text x="836" y="84" font-size="24" fill="#6B7280">32 tables · 30 functions</text>
|
||||
<text x="704" y="122" font-size="25" fill="#333333">All mapping data. The schema the</text>
|
||||
<text x="704" y="154" font-size="25" fill="#333333">field application reads.</text>
|
||||
|
||||
<rect x="704" y="184" width="444" height="86" rx="10" fill="#FFFFFF" stroke="#166534" stroke-width="2.5"/>
|
||||
<text x="726" y="218" font-size="26" font-weight="bold" fill="#166534">area_districts</text>
|
||||
<text x="726" y="252" font-size="23" fill="#333333">the district register — districtid</text>
|
||||
|
||||
<text x="704" y="316" font-size="24" fill="#6B7280">Everything else in spatial is scoped by</text>
|
||||
<text x="704" y="346" font-size="24" fill="#6B7280">districtid: parcels, zones, roads,</text>
|
||||
<text x="704" y="376" font-size="24" fill="#6B7280">facilities, contours, the UPN grid.</text>
|
||||
|
||||
<rect x="704" y="404" width="444" height="104" rx="10" fill="#FFFFFF" stroke="#9CA3AF" stroke-width="2" stroke-dasharray="7 5"/>
|
||||
<text x="726" y="440" font-size="24" fill="#333333">One foreign key leaves the four</text>
|
||||
<text x="726" y="470" font-size="24" fill="#333333">schemas entirely: zoning_districts</text>
|
||||
<text x="726" y="498" font-size="24" fill="#333333">→ reference.zoning_types.</text>
|
||||
|
||||
<!-- the shared identifier -->
|
||||
<path d="M434 110 C 540 110, 560 210, 700 222" fill="none" stroke="#6B7280" stroke-width="2.5" stroke-dasharray="8 6" marker-end="url(#d1)"/>
|
||||
<path d="M434 286 C 540 286, 560 230, 700 227" fill="none" stroke="#6B7280" stroke-width="2.5" stroke-dasharray="8 6" marker-end="url(#d1)"/>
|
||||
<path d="M434 462 C 540 462, 560 250, 700 234" fill="none" stroke="#6B7280" stroke-width="2.5" stroke-dasharray="8 6" marker-end="url(#d1)"/>
|
||||
|
||||
<text x="452" y="128" font-size="22" fill="#6B7280" stroke="#FFFFFF" stroke-width="7" paint-order="stroke" stroke-linejoin="round">district_id</text>
|
||||
<text x="452" y="272" font-size="22" fill="#6B7280" stroke="#FFFFFF" stroke-width="7" paint-order="stroke" stroke-linejoin="round">district_ref</text>
|
||||
<text x="452" y="448" font-size="22" fill="#6B7280" stroke="#FFFFFF" stroke-width="7" paint-order="stroke" stroke-linejoin="round">project_district_id</text>
|
||||
|
||||
<!-- footnote -->
|
||||
<line x1="24" y1="562" x2="1176" y2="562" stroke="#DCDDE9" stroke-width="2"/>
|
||||
<text x="24" y="596" font-size="23" fill="#6B7280">Dashed = joined by shared value, not by an enforced constraint. No foreign key crosses a schema boundary.</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.5 KiB |
Loading…
x
Reference in New Issue
Block a user