Stabilize the data model
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3539332. -->
Reported by: [claudiu.cristea](https://www.drupal.org/user/56348)
Related to !23
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>The module has 2 tables:</p>
<ul>
<li>A table storing references to source string occurrences/instance (currently <code>{babel_source}</code>)</li>
<li>The other storing a hash representing the a unique source string within a context (currently <code>{babel_source_status}</code>)</li>
</ul>
<p>There are two problems arising from this:</p>
<ol>
<li>The tables naming is misleading. The 1st table name should suggest that is not a list of source strings but a list of source string occurrences/instances. For instance a source string "Foo", in the "bar" context might appear multiple times in the 1st table, in code and also in a config. The 2nd table is the one that store unique references to a source string but its name is also misleading.</li>
<li>The 1st table column "sort_key" has duplicate values because the value is linked the a unique source string + context. If the source string has multiple occurrences/instances the value is needlessly duplicated.</li>
</ol>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<ol>
<li>Rename the current table <code>{babel_source}</code> as <code>{babel_source_instance}</code>.</li>
<li>Rename the current table <code>{babel_source_status}</code> as <code>{babel_source}</code>.</li>
<li>Move the "sort_key" from <code>{babel_source_instance}</code> (new name) to <code>{babel_source}</code> (new name).</li>
<li>Add "foreign keys" to schema definition for the hash column
</li></ol>
<h3 id="summary-remaining-tasks">Remaining tasks</h3>
<p>None.</p>
<h3 id="summary-ui-changes">User interface changes</h3>
<p>None.</p>
<h3 id="summary-api-changes">API changes</h3>
<p>None.</p>
<h3 id="summary-data-model-changes">Data model changes</h3>
<ul>
<li>Table names changed</li>
<li>Field "sort_key" moved to the other table</li>
</ul>
issue