<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://129.151.190.5/index.php?action=history&amp;feed=atom&amp;title=OpenRIMS_-_Database_Cleaning_Part_1</id>
	<title>OpenRIMS - Database Cleaning Part 1 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://129.151.190.5/index.php?action=history&amp;feed=atom&amp;title=OpenRIMS_-_Database_Cleaning_Part_1"/>
	<link rel="alternate" type="text/html" href="http://129.151.190.5/index.php?title=OpenRIMS_-_Database_Cleaning_Part_1&amp;action=history"/>
	<updated>2026-05-01T11:25:35Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.40.0</generator>
	<entry>
		<id>http://129.151.190.5/index.php?title=OpenRIMS_-_Database_Cleaning_Part_1&amp;diff=186&amp;oldid=prev</id>
		<title>Khoppenworth at 17:02, 23 July 2024</title>
		<link rel="alternate" type="text/html" href="http://129.151.190.5/index.php?title=OpenRIMS_-_Database_Cleaning_Part_1&amp;diff=186&amp;oldid=prev"/>
		<updated>2024-07-23T17:02:05Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 17:02, 23 July 2024&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l36&quot;&gt;Line 36:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 36:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  FROM tree_userdefined c&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  FROM tree_userdefined c&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;'''This script may run a long time!'''&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;'''This script may run &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;for &lt;/ins&gt;a long time!'''&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;After &lt;/del&gt;the script &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;run concludes please login as administrator &lt;/del&gt;and &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;verify that the script has cleaned the workflows&lt;/del&gt;.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;The results table created is &lt;/ins&gt;the &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;actual cleaning &lt;/ins&gt;script&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;. Now &quot;Select All&quot; from the table, copy &lt;/ins&gt;and &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;then paste into a New Query&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The easiest way is to go to the   &lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Click Run/Execute.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;'''This script will also run for a long time!'''&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;After the script has executed please login to OpenRIMS as administrator and verify that the script has cleaned the workflows.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The easiest way is to go to the &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Application Tracker of Monitor as verify that table is empty. &lt;/ins&gt;  &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== SQL Description of the cleaning process ==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== SQL Description of the cleaning process ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Khoppenworth</name></author>
	</entry>
	<entry>
		<id>http://129.151.190.5/index.php?title=OpenRIMS_-_Database_Cleaning_Part_1&amp;diff=185&amp;oldid=prev</id>
		<title>Khoppenworth: /* Generate cleaning script */</title>
		<link rel="alternate" type="text/html" href="http://129.151.190.5/index.php?title=OpenRIMS_-_Database_Cleaning_Part_1&amp;diff=185&amp;oldid=prev"/>
		<updated>2024-07-23T16:06:48Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Generate cleaning script&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;a href=&quot;http://129.151.190.5/index.php?title=OpenRIMS_-_Database_Cleaning_Part_1&amp;amp;diff=185&amp;amp;oldid=168&quot;&gt;Show changes&lt;/a&gt;</summary>
		<author><name>Khoppenworth</name></author>
	</entry>
	<entry>
		<id>http://129.151.190.5/index.php?title=OpenRIMS_-_Database_Cleaning_Part_1&amp;diff=168&amp;oldid=prev</id>
		<title>Khoppenworth: New Page</title>
		<link rel="alternate" type="text/html" href="http://129.151.190.5/index.php?title=OpenRIMS_-_Database_Cleaning_Part_1&amp;diff=168&amp;oldid=prev"/>
		<updated>2024-02-07T23:54:37Z</updated>

		<summary type="html">&lt;p&gt;New Page&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= Purpose =&lt;br /&gt;
              The OpenRIMS-RP database contains configuration and user-defined data. The configuration data is defined by Supervisor. This data intends to manage electronic forms and workflows of applications. The user-defined data is data collected using electronic forms of applications and workflows.&lt;br /&gt;
&lt;br /&gt;
              Before the database will become production it is necessary to define the primary configuration data. Because the configuration data is particular for a country, this data should be created and tested on the sandbox or demo installation of OpenRIMS-RP.&lt;br /&gt;
&lt;br /&gt;
              While testing, the test data will be created. Thus, to prepare a production database it will be necessary to clean up all user-defined data that was created while testing, presenting, and, possible, learning.&lt;br /&gt;
&lt;br /&gt;
For the current release, there is no special defined software to clean up the database, because it is an on-time operation.&lt;br /&gt;
&lt;br /&gt;
= Pre-conditions =&lt;br /&gt;
·       MySQL Workbench is installed&lt;br /&gt;
&lt;br /&gt;
·       Connection to the database is established&lt;br /&gt;
&lt;br /&gt;
·       Connection rights to the pdx2 database allow at least select, delete, insert, execute, update, show view&lt;br /&gt;
&lt;br /&gt;
= The approach =&lt;br /&gt;
              The conceptual model[1] of the OpenRIMS-RP database is a forest of data trees built upon a relation logical model using the MySQL database engine.&lt;br /&gt;
&lt;br /&gt;
              The stored procedure “print_tree” allows selecting all branches of a data tree from the root or any node.&lt;br /&gt;
&lt;br /&gt;
              Any tree in this forest is a configuration or user-defined data, but not both. The clean database assumed the absence of user-defined data. To remove the user-defined data all data trees that contain user-defined data should be removed.&lt;br /&gt;
&lt;br /&gt;
To remove a data tree, it will be enough to remove the data tree root using the “remove_branch” stored procedure.&lt;br /&gt;
&lt;br /&gt;
              Thus, it will be necessary to recognize all roots of user-defined data and remove them by the “remove_branch” stored procedure. &lt;br /&gt;
&lt;br /&gt;
              Currently, there are no SQL queries to select roots of the user-defined-data roots, however, SQL queries to select roots of the configurations have been developed for Administrative features implementations.&lt;br /&gt;
&lt;br /&gt;
              The approach is to select all roots of configurations and, then, subtract them from the whole roots.&lt;br /&gt;
&lt;br /&gt;
= Roots of configurations =&lt;br /&gt;
              The data tree roots as well as all data tree nodes are recorded in the “concept” table. All roots can be selected using the “tree_roots” view.&lt;br /&gt;
&lt;br /&gt;
              This view is a result of SQL query&lt;br /&gt;
&lt;br /&gt;
SELECT&lt;br /&gt;
&lt;br /&gt;
      `concept`.`ID` AS `ID`,&lt;br /&gt;
&lt;br /&gt;
      `concept`.`Identifier` AS `Identifier`&lt;br /&gt;
&lt;br /&gt;
   FROM&lt;br /&gt;
&lt;br /&gt;
      `concept`&lt;br /&gt;
&lt;br /&gt;
       LEFT JOIN `closure` `clos` ON `clos`.`childID` = `concept`.`ID`  AND (`clos`.`Level` &amp;lt;&amp;gt; 0)&lt;br /&gt;
&lt;br /&gt;
   WHERE&lt;br /&gt;
&lt;br /&gt;
      ISNULL(`clos`.`ID`) and `concept`.`Active` -- only roots&lt;br /&gt;
&lt;br /&gt;
Each data tree root is defined by unique field “Identifier”.&lt;br /&gt;
&lt;br /&gt;
The data configuration trees are:&lt;br /&gt;
&lt;br /&gt;
1.     Authorities and users&lt;br /&gt;
&lt;br /&gt;
2.     Workflows&lt;br /&gt;
&lt;br /&gt;
3.     Dictionaries&lt;br /&gt;
&lt;br /&gt;
4.     Resources&lt;br /&gt;
&lt;br /&gt;
5.     Files uploaded to resources&lt;br /&gt;
&lt;br /&gt;
6.     Configurations of data&lt;br /&gt;
&lt;br /&gt;
7.     Configurations of reports&lt;br /&gt;
&lt;br /&gt;
8.     Tiles&lt;br /&gt;
&lt;br /&gt;
9.     Legacy data&lt;br /&gt;
&lt;br /&gt;
These configurations will not be extended until the next version of OpenRIMS-RP software.&lt;br /&gt;
&lt;br /&gt;
= Authorities and users =&lt;br /&gt;
              All users are branches of a tree. The root of this tree is “user.data”.&lt;br /&gt;
&lt;br /&gt;
All authorities are branches of a tree “organization.authority”.&lt;br /&gt;
&lt;br /&gt;
              The SQL query to select roots:&lt;br /&gt;
&lt;br /&gt;
SELECT c.ID, c.Identifier&lt;br /&gt;
&lt;br /&gt;
FROM concept c&lt;br /&gt;
&lt;br /&gt;
left join closure clo on clo.childID=c.ID and clo.Level&amp;lt;&amp;gt;0&lt;br /&gt;
&lt;br /&gt;
where clo.ID is null and c.Active and c.Identifier in ('organization.authority', 'user.data')&lt;br /&gt;
&lt;br /&gt;
= Workflow definitions =&lt;br /&gt;
              Workflow definitions allow control user’s application processing.&lt;br /&gt;
&lt;br /&gt;
              The definition of a workflow is stored in a tree. The root URL is “configuration.”URL of a workflow”, e.g., “configuration.application.retail.site.owned.pvt”. All root URLs can be gotten from lifecycle dictionaries:&lt;br /&gt;
&lt;br /&gt;
·       dictionary.guest.deregistration&lt;br /&gt;
&lt;br /&gt;
·       dictionary.guest.amendments&lt;br /&gt;
&lt;br /&gt;
·       dictionary.guest.applications&lt;br /&gt;
&lt;br /&gt;
·       dictionary.guest.renewal&lt;br /&gt;
&lt;br /&gt;
·       dictionary.shutdown.applications&lt;br /&gt;
&lt;br /&gt;
·       dictionary.host.applications&lt;br /&gt;
&lt;br /&gt;
The SQL query to select all root URL’s from the life cycle dictionaries is:&lt;br /&gt;
&lt;br /&gt;
SELECT distinct concat('configuration.',val.Label)&lt;br /&gt;
&lt;br /&gt;
FROM concept c&lt;br /&gt;
&lt;br /&gt;
join closure clo1 on clo1.parentID=c.ID and clo1.`Level`=3&lt;br /&gt;
&lt;br /&gt;
join concept var on var.ID=clo1.childID and var.Identifier='applicationurl'&lt;br /&gt;
&lt;br /&gt;
join closure clo2 on clo2.parentID=var.ID and clo2.Level=1&lt;br /&gt;
&lt;br /&gt;
join concept val on val.ID=clo2.childID and val.Identifier='EN_US'&lt;br /&gt;
&lt;br /&gt;
left join closure clo on clo.childID=c.ID and clo.Level&amp;lt;&amp;gt;0&lt;br /&gt;
&lt;br /&gt;
where&lt;br /&gt;
&lt;br /&gt;
clo.ID is null and&lt;br /&gt;
&lt;br /&gt;
c.Identifier in (&lt;br /&gt;
&lt;br /&gt;
'dictionary.guest.deregistration',&lt;br /&gt;
&lt;br /&gt;
'dictionary.guest.amendments',&lt;br /&gt;
&lt;br /&gt;
'dictionary.guest.applications',&lt;br /&gt;
&lt;br /&gt;
'dictionary.guest.renewal',&lt;br /&gt;
&lt;br /&gt;
'dictionary.shutdown.applications',&lt;br /&gt;
&lt;br /&gt;
'dictionary.host.applications'&lt;br /&gt;
&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
              The SQL to select all workflow definition roots is&lt;br /&gt;
&lt;br /&gt;
SELECT c.ID, c.Identifier&lt;br /&gt;
&lt;br /&gt;
FROM concept c&lt;br /&gt;
&lt;br /&gt;
left join closure clo on clo.childID=c.ID and clo.Level&amp;lt;&amp;gt;0&lt;br /&gt;
&lt;br /&gt;
where clo.ID is null and c.Active and c.Identifier in (&lt;br /&gt;
&lt;br /&gt;
                                             -- query for workflow definition URLs from the lifecycle dictionaries&lt;br /&gt;
&lt;br /&gt;
                                             SELECT distinct concat('configuration.',val.Label)&lt;br /&gt;
&lt;br /&gt;
                                             FROM concept c&lt;br /&gt;
&lt;br /&gt;
                                             join closure clo1 on clo1.parentID=c.ID and clo1.`Level`=3&lt;br /&gt;
&lt;br /&gt;
                                             join concept var on var.ID=clo1.childID and var.Identifier='applicationurl'&lt;br /&gt;
&lt;br /&gt;
                                             join closure clo2 on clo2.parentID=var.ID and clo2.Level=1&lt;br /&gt;
&lt;br /&gt;
                                             join concept val on val.ID=clo2.childID and val.Identifier='EN_US'&lt;br /&gt;
&lt;br /&gt;
                                             left join closure clo on clo.childID=c.ID and clo.Level&amp;lt;&amp;gt;0&lt;br /&gt;
&lt;br /&gt;
                                             where&lt;br /&gt;
&lt;br /&gt;
                                             clo.ID is null and&lt;br /&gt;
&lt;br /&gt;
                                             c.Identifier in (&lt;br /&gt;
&lt;br /&gt;
                                             'dictionary.guest.deregistration',&lt;br /&gt;
&lt;br /&gt;
                                             'dictionary.guest.amendments',&lt;br /&gt;
&lt;br /&gt;
                                             'dictionary.guest.applications',&lt;br /&gt;
&lt;br /&gt;
                                             'dictionary.guest.renewal',&lt;br /&gt;
&lt;br /&gt;
                                             'dictionary.shutdown.applications',&lt;br /&gt;
&lt;br /&gt;
                                             'dictionary.host.applications'&lt;br /&gt;
&lt;br /&gt;
                                             )&lt;br /&gt;
&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
= Dictionaries =&lt;br /&gt;
              Dictionaries contains pre-defined classifiers used by data input forms. Each dictionary is a tree.&lt;br /&gt;
&lt;br /&gt;
              By the agreement, all URLs of dictionaries should start with “dictionary.”. Thus, SQL is&lt;br /&gt;
&lt;br /&gt;
SELECT c.ID, c.Identifier&lt;br /&gt;
&lt;br /&gt;
FROM concept c&lt;br /&gt;
&lt;br /&gt;
left join closure clo on clo.childID=c.ID and clo.Level&amp;lt;&amp;gt;0&lt;br /&gt;
&lt;br /&gt;
where clo.ID is null and c.Active and c.Identifier like 'dictionary.%'&lt;br /&gt;
&lt;br /&gt;
= Resources =&lt;br /&gt;
              The definition of a resource consists of:&lt;br /&gt;
&lt;br /&gt;
1.     Resource definition&lt;br /&gt;
&lt;br /&gt;
2.     Data configuration&lt;br /&gt;
&lt;br /&gt;
3.     Dictionary&lt;br /&gt;
&lt;br /&gt;
4.     Stored files&lt;br /&gt;
&lt;br /&gt;
The data configuration and dictionary are common configuration trees,  that can be gotten by the appropriate SQLs (see above and below)&lt;br /&gt;
&lt;br /&gt;
Resource definitions are branches of the root URL “configuration.resources”.&lt;br /&gt;
&lt;br /&gt;
The SQL is&lt;br /&gt;
&lt;br /&gt;
SELECT c.ID, c.Identifier&lt;br /&gt;
&lt;br /&gt;
FROM concept c&lt;br /&gt;
&lt;br /&gt;
left join closure clo on clo.childID=c.ID and clo.Level&amp;lt;&amp;gt;0&lt;br /&gt;
&lt;br /&gt;
where clo.ID is null and c.Active and c.Identifier='configuration.resources'&lt;br /&gt;
&lt;br /&gt;
= Files, uploaded to resources =&lt;br /&gt;
The resource files are stored in a tree for each resource. The root URL is defined in the resource data configurations. A data configuration of a resource is a uniform data configuration.  Thus, it is necessary:&lt;br /&gt;
&lt;br /&gt;
1.     Select URLs of data configurations for all resources&lt;br /&gt;
&lt;br /&gt;
2.     Select data configurations for all resources, using data configuration URLs&lt;br /&gt;
&lt;br /&gt;
3.     Select URLs of file trees from the data configurations&lt;br /&gt;
&lt;br /&gt;
4.     Select file trees, using the URLs&lt;br /&gt;
&lt;br /&gt;
URLs of data configurations for all resources&lt;br /&gt;
&lt;br /&gt;
SELECT item.Label&lt;br /&gt;
&lt;br /&gt;
FROM concept c&lt;br /&gt;
&lt;br /&gt;
join closure clo1 on clo1.parentID=c.ID and clo1.`Level`=1&lt;br /&gt;
&lt;br /&gt;
join concept lang on lang.ID=clo1.childID and lang.Identifier='EN_US'&lt;br /&gt;
&lt;br /&gt;
join closure clo2 on clo2.parentID=lang.ID and clo2.`Level`=1&lt;br /&gt;
&lt;br /&gt;
join concept item on item.ID=clo2.childID&lt;br /&gt;
&lt;br /&gt;
left join closure clo on clo.childID=c.ID and clo.`Level`&amp;lt;&amp;gt;0&lt;br /&gt;
&lt;br /&gt;
where&lt;br /&gt;
&lt;br /&gt;
clo.ID is null and&lt;br /&gt;
&lt;br /&gt;
item.Active and&lt;br /&gt;
&lt;br /&gt;
c.Active and&lt;br /&gt;
&lt;br /&gt;
c.Identifier='configuration.resources'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Data configurations for all resources:&lt;br /&gt;
&lt;br /&gt;
SELECT conf.ID, conf.Identifier&lt;br /&gt;
&lt;br /&gt;
FROM concept c&lt;br /&gt;
&lt;br /&gt;
join closure clo1 on clo1.parentID=c.ID and clo1.`Level`=1&lt;br /&gt;
&lt;br /&gt;
join concept conf on conf.ID=clo1.childID&lt;br /&gt;
&lt;br /&gt;
left join closure clo on clo.childID=c.ID and clo.Level&amp;lt;&amp;gt;0&lt;br /&gt;
&lt;br /&gt;
where clo.ID is null&lt;br /&gt;
&lt;br /&gt;
and c.Active&lt;br /&gt;
&lt;br /&gt;
and c.Identifier in ('configuration.data')&lt;br /&gt;
&lt;br /&gt;
and conf.Identifier in (&lt;br /&gt;
&lt;br /&gt;
                              -- URLs of data configurations for all resources&lt;br /&gt;
&lt;br /&gt;
                              SELECT item.Label&lt;br /&gt;
&lt;br /&gt;
                              FROM concept c&lt;br /&gt;
&lt;br /&gt;
                              join closure clo1 on clo1.parentID=c.ID and clo1.`Level`=1&lt;br /&gt;
&lt;br /&gt;
                              join concept lang on lang.ID=clo1.childID and lang.Identifier='EN_US'&lt;br /&gt;
&lt;br /&gt;
                              join closure clo2 on clo2.parentID=lang.ID and clo2.`Level`=1&lt;br /&gt;
&lt;br /&gt;
                              join concept item on item.ID=clo2.childID&lt;br /&gt;
&lt;br /&gt;
                              left join closure clo on clo.childID=c.ID and clo.`Level`&amp;lt;&amp;gt;0&lt;br /&gt;
&lt;br /&gt;
                              where&lt;br /&gt;
&lt;br /&gt;
                              clo.ID is null and&lt;br /&gt;
&lt;br /&gt;
                              item.Active and&lt;br /&gt;
&lt;br /&gt;
                               c.Active and&lt;br /&gt;
&lt;br /&gt;
                               c.Identifier='configuration.resources'&lt;br /&gt;
&lt;br /&gt;
)            &lt;br /&gt;
&lt;br /&gt;
URLs of file trees from the data configurations&lt;br /&gt;
&lt;br /&gt;
SELECT asm.Url&lt;br /&gt;
&lt;br /&gt;
              FROM concept c  -- roots of configurations (right table on the screen)&lt;br /&gt;
&lt;br /&gt;
   -- variables for configurations (left table on the screen)&lt;br /&gt;
&lt;br /&gt;
              join closure clo1 on clo1.parentID=c.ID and clo1.`Level`=1&lt;br /&gt;
&lt;br /&gt;
              join concept conf on conf.ID=clo1.childID&lt;br /&gt;
&lt;br /&gt;
              join closure clo2 on clo2.parentID=conf.ID and clo2.Level='1'&lt;br /&gt;
&lt;br /&gt;
              join concept var on var.ID=clo2.childID and var.Identifier &amp;lt;&amp;gt; '_LITERALS_' and var.Active&lt;br /&gt;
&lt;br /&gt;
   -- get only files (documents) from the configuration variables&lt;br /&gt;
&lt;br /&gt;
              join assembly asm on asm.conceptID=var.ID and asm.Clazz='documents'&lt;br /&gt;
&lt;br /&gt;
   -- roots&lt;br /&gt;
&lt;br /&gt;
              left join closure clo on clo.childID=c.ID and clo.Level&amp;lt;&amp;gt;0&lt;br /&gt;
&lt;br /&gt;
              where clo.ID is null&lt;br /&gt;
&lt;br /&gt;
               and c.Active&lt;br /&gt;
&lt;br /&gt;
               and c.Identifier in ('configuration.data')&lt;br /&gt;
&lt;br /&gt;
               and conf.Identifier in (&lt;br /&gt;
&lt;br /&gt;
                                             -- URLs of data configurations for all resources&lt;br /&gt;
&lt;br /&gt;
                                             SELECT item.Label&lt;br /&gt;
&lt;br /&gt;
                                             FROM concept c&lt;br /&gt;
&lt;br /&gt;
                                             join closure clo1 on clo1.parentID=c.ID and clo1.`Level`=1&lt;br /&gt;
&lt;br /&gt;
                                             join concept lang on lang.ID=clo1.childID and lang.Identifier='EN_US'&lt;br /&gt;
&lt;br /&gt;
                                             join closure clo2 on clo2.parentID=lang.ID and clo2.`Level`=1&lt;br /&gt;
&lt;br /&gt;
                                             join concept item on item.ID=clo2.childID&lt;br /&gt;
&lt;br /&gt;
                                             left join closure clo on clo.childID=c.ID and clo.`Level`&amp;lt;&amp;gt;0&lt;br /&gt;
&lt;br /&gt;
                                             where&lt;br /&gt;
&lt;br /&gt;
                                             clo.ID is null and&lt;br /&gt;
&lt;br /&gt;
                                             item.Active and&lt;br /&gt;
&lt;br /&gt;
                                              c.Active and&lt;br /&gt;
&lt;br /&gt;
                                              c.Identifier='configuration.resources'&lt;br /&gt;
&lt;br /&gt;
               )&lt;br /&gt;
&lt;br /&gt;
File trees:&lt;br /&gt;
&lt;br /&gt;
SELECT c.ID, c.Identifier&lt;br /&gt;
&lt;br /&gt;
FROM concept c&lt;br /&gt;
&lt;br /&gt;
left join closure clo on clo.childID=c.ID and clo.Level&amp;lt;&amp;gt;0&lt;br /&gt;
&lt;br /&gt;
where clo.ID is null and c.Active and c.Identifier in&lt;br /&gt;
&lt;br /&gt;
(&lt;br /&gt;
&lt;br /&gt;
       -- URLs of file trees from the data configurations&lt;br /&gt;
&lt;br /&gt;
       SELECT asm.Url&lt;br /&gt;
&lt;br /&gt;
       FROM concept c  -- roots of configurations (right table on the screen)&lt;br /&gt;
&lt;br /&gt;
  -- variables for configurations (left table on the screen)&lt;br /&gt;
&lt;br /&gt;
       join closure clo1 on clo1.parentID=c.ID and clo1.`Level`=1&lt;br /&gt;
&lt;br /&gt;
       join concept conf on conf.ID=clo1.childID&lt;br /&gt;
&lt;br /&gt;
       join closure clo2 on clo2.parentID=conf.ID and clo2.Level='1'&lt;br /&gt;
&lt;br /&gt;
       join concept var on var.ID=clo2.childID and var.Identifier &amp;lt;&amp;gt; '_LITERALS_' and var.Active&lt;br /&gt;
&lt;br /&gt;
  -- get only files (documents) from the configuration variables&lt;br /&gt;
&lt;br /&gt;
       join assembly asm on asm.conceptID=var.ID and asm.Clazz='documents'&lt;br /&gt;
&lt;br /&gt;
  -- roots&lt;br /&gt;
&lt;br /&gt;
       left join closure clo on clo.childID=c.ID and clo.Level&amp;lt;&amp;gt;0&lt;br /&gt;
&lt;br /&gt;
       where clo.ID is null&lt;br /&gt;
&lt;br /&gt;
        and c.Active&lt;br /&gt;
&lt;br /&gt;
        and c.Identifier in ('configuration.data')&lt;br /&gt;
&lt;br /&gt;
        and conf.Identifier in (&lt;br /&gt;
&lt;br /&gt;
                                      -- URLs of data configurations for all resources&lt;br /&gt;
&lt;br /&gt;
                                      SELECT item.Label&lt;br /&gt;
&lt;br /&gt;
                                      FROM concept c&lt;br /&gt;
&lt;br /&gt;
                                      join closure clo1 on clo1.parentID=c.ID and clo1.`Level`=1&lt;br /&gt;
&lt;br /&gt;
                                      join concept lang on lang.ID=clo1.childID and lang.Identifier='EN_US'&lt;br /&gt;
&lt;br /&gt;
                                      join closure clo2 on clo2.parentID=lang.ID and clo2.`Level`=1&lt;br /&gt;
&lt;br /&gt;
                                      join concept item on item.ID=clo2.childID&lt;br /&gt;
&lt;br /&gt;
                                      left join closure clo on clo.childID=c.ID and clo.`Level`&amp;lt;&amp;gt;0&lt;br /&gt;
&lt;br /&gt;
                                      where&lt;br /&gt;
&lt;br /&gt;
                                      clo.ID is null and&lt;br /&gt;
&lt;br /&gt;
                                      item.Active and&lt;br /&gt;
&lt;br /&gt;
                                       c.Active and&lt;br /&gt;
&lt;br /&gt;
                                       c.Identifier='configuration.resources'&lt;br /&gt;
&lt;br /&gt;
        )&lt;br /&gt;
&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
= Configurations of data =&lt;br /&gt;
              Configurations of data intends to manage on-screen forms for configurations and user-defined data  For each form the configuration allows to assign:&lt;br /&gt;
&lt;br /&gt;
·       Form layout on a screen&lt;br /&gt;
&lt;br /&gt;
·       Data input fields, i.e., text, numeric, dates, logical&lt;br /&gt;
&lt;br /&gt;
·       Data input components, i.e., dictionaries, registers, resource downloads, etc.&lt;br /&gt;
&lt;br /&gt;
·       Data validation rules&lt;br /&gt;
&lt;br /&gt;
              Details may be found here (MSH, 2022)&lt;br /&gt;
&lt;br /&gt;
              For each data form the configuration is a branch in the tree with URL “configuration.data”&lt;br /&gt;
&lt;br /&gt;
The SQL is&lt;br /&gt;
&lt;br /&gt;
SELECT c.ID, c.Identifier&lt;br /&gt;
&lt;br /&gt;
FROM concept c&lt;br /&gt;
&lt;br /&gt;
left join closure clo on clo.childID=c.ID and clo.Level&amp;lt;&amp;gt;0&lt;br /&gt;
&lt;br /&gt;
where clo.ID is null and c.Active and c.Identifier in ('configuration.data')&lt;br /&gt;
&lt;br /&gt;
= Configurations of reports =&lt;br /&gt;
              Configurations of internal reports intend to define parameters to execute internal reports. For each report configuration is a branch in a tree with root URL “report.configuration”&lt;br /&gt;
&lt;br /&gt;
The SQL is&lt;br /&gt;
&lt;br /&gt;
SELECT c.ID, c.Identifier&lt;br /&gt;
&lt;br /&gt;
FROM concept c&lt;br /&gt;
&lt;br /&gt;
left join closure clo on clo.childID=c.ID and clo.Level&amp;lt;&amp;gt;0&lt;br /&gt;
&lt;br /&gt;
where clo.ID is null and c.Active and c.Identifier in ('report.configuration')&lt;br /&gt;
&lt;br /&gt;
= Tiles =&lt;br /&gt;
              Tiles is a system dictionary “dictionary.system.tiles”&lt;br /&gt;
&lt;br /&gt;
= Legacy Data =&lt;br /&gt;
              The legacy data may be placed to one or more trees. The URLs of the roots should be clarified for the installation. For Nepal database URLs are “system.import.legacy.data”, “legacy.pharmacies” and “legacy.ws”.&lt;br /&gt;
&lt;br /&gt;
The SQL is&lt;br /&gt;
&lt;br /&gt;
SELECT c.ID, c.Identifier&lt;br /&gt;
&lt;br /&gt;
FROM concept c&lt;br /&gt;
&lt;br /&gt;
left join closure clo on clo.childID=c.ID and clo.Level&amp;lt;&amp;gt;0&lt;br /&gt;
&lt;br /&gt;
where clo.ID is null and c.Active and c.Identifier in ('legacy.pharmacies', 'legacy.ws', 'system.import.legacy.data')&lt;br /&gt;
&lt;br /&gt;
= Put it all together =&lt;br /&gt;
Create two database views:&lt;br /&gt;
&lt;br /&gt;
'''tree_configurations:'''&lt;br /&gt;
&lt;br /&gt;
-- 1.        Authorities and users&lt;br /&gt;
&lt;br /&gt;
SELECT c.ID, c.Identifier&lt;br /&gt;
&lt;br /&gt;
FROM concept c&lt;br /&gt;
&lt;br /&gt;
left join closure clo on clo.childID=c.ID and clo.Level&amp;lt;&amp;gt;0&lt;br /&gt;
&lt;br /&gt;
where clo.ID is null and c.Active and c.Identifier in ('organization.authority', 'user.data')&lt;br /&gt;
&lt;br /&gt;
union&lt;br /&gt;
&lt;br /&gt;
-- 2.        Workflows&lt;br /&gt;
&lt;br /&gt;
SELECT c.ID, c.Identifier&lt;br /&gt;
&lt;br /&gt;
FROM concept c&lt;br /&gt;
&lt;br /&gt;
left join closure clo on clo.childID=c.ID and clo.Level&amp;lt;&amp;gt;0&lt;br /&gt;
&lt;br /&gt;
where clo.ID is null and c.Active and c.Identifier in (&lt;br /&gt;
&lt;br /&gt;
                                             -- query for workflow definition URLs from the lifecycle dictionaries&lt;br /&gt;
&lt;br /&gt;
                                             SELECT distinct concat('configuration.',val.Label)&lt;br /&gt;
&lt;br /&gt;
                                             FROM concept c&lt;br /&gt;
&lt;br /&gt;
                                             join closure clo1 on clo1.parentID=c.ID and clo1.`Level`=3&lt;br /&gt;
&lt;br /&gt;
                                             join concept var on var.ID=clo1.childID and var.Identifier='applicationurl'&lt;br /&gt;
&lt;br /&gt;
                                             join closure clo2 on clo2.parentID=var.ID and clo2.Level=1&lt;br /&gt;
&lt;br /&gt;
                                             join concept val on val.ID=clo2.childID and val.Identifier='EN_US'&lt;br /&gt;
&lt;br /&gt;
                                             left join closure clo on clo.childID=c.ID and clo.Level&amp;lt;&amp;gt;0&lt;br /&gt;
&lt;br /&gt;
                                             where&lt;br /&gt;
&lt;br /&gt;
                                             clo.ID is null and&lt;br /&gt;
&lt;br /&gt;
                                             c.Identifier in (&lt;br /&gt;
&lt;br /&gt;
                                             'dictionary.guest.deregistration',&lt;br /&gt;
&lt;br /&gt;
                                             'dictionary.guest.amendments',&lt;br /&gt;
&lt;br /&gt;
                                             'dictionary.guest.applications',&lt;br /&gt;
&lt;br /&gt;
                                             'dictionary.guest.renewal',&lt;br /&gt;
&lt;br /&gt;
                                             'dictionary.shutdown.applications',&lt;br /&gt;
&lt;br /&gt;
                                             'dictionary.host.applications'&lt;br /&gt;
&lt;br /&gt;
                                             )&lt;br /&gt;
&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
union&lt;br /&gt;
&lt;br /&gt;
-- 3.        Dictionaries&lt;br /&gt;
&lt;br /&gt;
SELECT c.ID, c.Identifier&lt;br /&gt;
&lt;br /&gt;
FROM concept c&lt;br /&gt;
&lt;br /&gt;
left join closure clo on clo.childID=c.ID and clo.Level&amp;lt;&amp;gt;0&lt;br /&gt;
&lt;br /&gt;
where clo.ID is null and c.Active and c.Identifier like 'dictionary.%'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
union&lt;br /&gt;
&lt;br /&gt;
-- 4.        Resources&lt;br /&gt;
&lt;br /&gt;
SELECT c.ID, c.Identifier&lt;br /&gt;
&lt;br /&gt;
FROM concept c&lt;br /&gt;
&lt;br /&gt;
left join closure clo on clo.childID=c.ID and clo.Level&amp;lt;&amp;gt;0&lt;br /&gt;
&lt;br /&gt;
where clo.ID is null and c.Active and c.Identifier='configuration.resources'&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
union&lt;br /&gt;
&lt;br /&gt;
-- 5.       Files uploaded to resources&lt;br /&gt;
&lt;br /&gt;
SELECT c.ID, c.Identifier&lt;br /&gt;
&lt;br /&gt;
FROM concept c&lt;br /&gt;
&lt;br /&gt;
left join closure clo on clo.childID=c.ID and clo.Level&amp;lt;&amp;gt;0&lt;br /&gt;
&lt;br /&gt;
where clo.ID is null and c.Active and c.Identifier in&lt;br /&gt;
&lt;br /&gt;
(&lt;br /&gt;
&lt;br /&gt;
              -- URLs of file trees from the data configurations&lt;br /&gt;
&lt;br /&gt;
              SELECT asm.Url&lt;br /&gt;
&lt;br /&gt;
              FROM concept c  -- roots of configurations (right table on the screen)&lt;br /&gt;
&lt;br /&gt;
   -- variables for configurations (left table on the screen)&lt;br /&gt;
&lt;br /&gt;
              join closure clo1 on clo1.parentID=c.ID and clo1.`Level`=1&lt;br /&gt;
&lt;br /&gt;
              join concept conf on conf.ID=clo1.childID&lt;br /&gt;
&lt;br /&gt;
              join closure clo2 on clo2.parentID=conf.ID and clo2.Level='1'&lt;br /&gt;
&lt;br /&gt;
              join concept var on var.ID=clo2.childID and var.Identifier &amp;lt;&amp;gt; '_LITERALS_' and var.Active&lt;br /&gt;
&lt;br /&gt;
   -- get only files (documents) from the configuration variables&lt;br /&gt;
&lt;br /&gt;
              join assembly asm on asm.conceptID=var.ID and asm.Clazz='documents'&lt;br /&gt;
&lt;br /&gt;
   -- roots&lt;br /&gt;
&lt;br /&gt;
              left join closure clo on clo.childID=c.ID and clo.Level&amp;lt;&amp;gt;0&lt;br /&gt;
&lt;br /&gt;
              where clo.ID is null&lt;br /&gt;
&lt;br /&gt;
               and c.Active&lt;br /&gt;
&lt;br /&gt;
               and c.Identifier in ('configuration.data')&lt;br /&gt;
&lt;br /&gt;
               and conf.Identifier in (&lt;br /&gt;
&lt;br /&gt;
                                             -- URLs of data configurations for all resources&lt;br /&gt;
&lt;br /&gt;
                                             SELECT item.Label&lt;br /&gt;
&lt;br /&gt;
                                             FROM concept c&lt;br /&gt;
&lt;br /&gt;
                                             join closure clo1 on clo1.parentID=c.ID and clo1.`Level`=1&lt;br /&gt;
&lt;br /&gt;
                                             join concept lang on lang.ID=clo1.childID and lang.Identifier='EN_US'&lt;br /&gt;
&lt;br /&gt;
                                             join closure clo2 on clo2.parentID=lang.ID and clo2.`Level`=1&lt;br /&gt;
&lt;br /&gt;
                                             join concept item on item.ID=clo2.childID&lt;br /&gt;
&lt;br /&gt;
                                             left join closure clo on clo.childID=c.ID and clo.`Level`&amp;lt;&amp;gt;0&lt;br /&gt;
&lt;br /&gt;
                                             where&lt;br /&gt;
&lt;br /&gt;
                                             clo.ID is null and&lt;br /&gt;
&lt;br /&gt;
                                             item.Active and&lt;br /&gt;
&lt;br /&gt;
                                              c.Active and&lt;br /&gt;
&lt;br /&gt;
                                              c.Identifier='configuration.resources'&lt;br /&gt;
&lt;br /&gt;
               )&lt;br /&gt;
&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
union&lt;br /&gt;
&lt;br /&gt;
-- 6.        Configurations of data&lt;br /&gt;
&lt;br /&gt;
SELECT c.ID, c.Identifier&lt;br /&gt;
&lt;br /&gt;
FROM concept c&lt;br /&gt;
&lt;br /&gt;
left join closure clo on clo.childID=c.ID and clo.Level&amp;lt;&amp;gt;0&lt;br /&gt;
&lt;br /&gt;
where clo.ID is null and c.Active and c.Identifier in ('configuration.data')&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
union&lt;br /&gt;
&lt;br /&gt;
-- 7.        Configurations of reports&lt;br /&gt;
&lt;br /&gt;
SELECT c.ID, c.Identifier&lt;br /&gt;
&lt;br /&gt;
FROM concept c&lt;br /&gt;
&lt;br /&gt;
left join closure clo on clo.childID=c.ID and clo.Level&amp;lt;&amp;gt;0&lt;br /&gt;
&lt;br /&gt;
where clo.ID is null and c.Active and c.Identifier in ('report.configuration')&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
union&lt;br /&gt;
&lt;br /&gt;
-- 8.        Tiles are a dictionary&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- 9.        Legacy data&lt;br /&gt;
&lt;br /&gt;
SELECT c.ID, c.Identifier&lt;br /&gt;
&lt;br /&gt;
FROM concept c&lt;br /&gt;
&lt;br /&gt;
left join closure clo on clo.childID=c.ID and clo.Level&amp;lt;&amp;gt;0&lt;br /&gt;
&lt;br /&gt;
where clo.ID is null and c.Active and c.Identifier in ('legacy.pharmacies', 'legacy.ws', 'system.import.legacy.data')&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''tree_userdefined:'''&lt;br /&gt;
&lt;br /&gt;
SELECT c.*&lt;br /&gt;
&lt;br /&gt;
   FROM&lt;br /&gt;
&lt;br /&gt;
              `concept` `c`&lt;br /&gt;
&lt;br /&gt;
       LEFT JOIN `closure` `clo` ON `clo`.`childID` = `c`.`ID`&lt;br /&gt;
&lt;br /&gt;
           AND (`clo`.`Level` &amp;lt;&amp;gt; 0)&lt;br /&gt;
&lt;br /&gt;
   WHERE&lt;br /&gt;
&lt;br /&gt;
      ISNULL(`clo`.`ID`) AND `c`.`Active`&lt;br /&gt;
&lt;br /&gt;
           AND NOT  `c`.`ID` IN (SELECT&lt;br /&gt;
&lt;br /&gt;
              `tree_configurations`.`ID`&lt;br /&gt;
&lt;br /&gt;
           FROM&lt;br /&gt;
&lt;br /&gt;
               `tree_configurations`)&lt;br /&gt;
&lt;br /&gt;
= Generate cleaning script =&lt;br /&gt;
SELECT concat('call remove_branch(',c.ID, ');', '-- ', c.Identifier) as 'sql'&lt;br /&gt;
&lt;br /&gt;
FROM tree_userdefined c&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
              This script may run a long time.&lt;br /&gt;
----[1] sciencedirect.com/topics/computer-science/conceptual-data-model&lt;/div&gt;</summary>
		<author><name>Khoppenworth</name></author>
	</entry>
</feed>