{"id":663,"date":"2025-12-03T08:58:00","date_gmt":"2025-12-03T08:58:00","guid":{"rendered":"https:\/\/academicsociety.org\/aicyberjournal\/?p=663"},"modified":"2026-03-14T04:46:56","modified_gmt":"2026-03-14T04:46:56","slug":"matbase-algorithm-for-translating-emdm-schemes-into-e-r-data-models","status":"publish","type":"post","link":"https:\/\/academicsociety.org\/aicyberjournal\/2025\/12\/03\/matbase-algorithm-for-translating-emdm-schemes-into-e-r-data-models\/","title":{"rendered":"MatBase algorithm for translating (E)MDM schemes into E-R data models"},"content":{"rendered":"\n<p>1. Introduction&nbsp;<\/p>\n\n\n\n<p>All subuniverses of discourse are governed by business rules (e.g., \u201dnobody may die before&nbsp; birth\u201d, \u201dnobody may get married before birth\u201d, \u201dpeople\u2019s height is between 30 and 225 cm\u201d,&nbsp; etc.). A database (db) instance is useful only if it is plausible, i.e., only if its data does not violate&nbsp; any business rule governing the corresponding subuniverse of discourse. In dbs and software&nbsp;<\/p>\n\n\n\n<p>engineering, business rules are formalized as constraints, i.e., closed formulas of the first-order&nbsp; predicate calculus with equality.&nbsp;&nbsp;<\/p>\n\n\n\n<p>Our (Elementary) Mathematical Data Model ((E)MDM) [1] was introduced as an&nbsp; intermediate conceptual design level between the Entity-Relational Data Model (E-RDM) [2,&nbsp; 3, 4] and the Relational Data Model (RDM) [4, 5, 6]. The E-RDM includes the very powerful&nbsp; E-R Diagrams (E-RDs) that may be easily understood even by customers without computer&nbsp; science background but, despite its many extensions, it has a very limited set of constraints.&nbsp; The RDM has only six constraint types (domain\/range, not null, default values, unique keys,&nbsp; foreign keys, and tuple\/check). The (E)MDM has 76 constraint types, thus allowing for far&nbsp; more accurate conceptual data modeling and db design; they include, explicitly or implicitly,&nbsp; all 6 relational type ones; the non-relational type ones should be enforced by the software&nbsp; applications (sa) that manage the corresponding dbs.&nbsp;<\/p>\n\n\n\n<p>In [4], we defined E-R data models as triples &lt;<em>ERDS<\/em>, <em>ARS<\/em>, <em>ICSD<\/em>&gt;, where <em>ERDS <\/em>is a set of&nbsp; E-RDs, <em>ARS <\/em>is an Associated Restriction Set, and <em>ICSD <\/em>is an Informal Corresponding Sub universe Description. The associated restrictions, which correspond to the business rules&nbsp; governing the modeled sub-universes, are of the following five types: inclusions between&nbsp; object sets (e.g., <em>EMPLOYEES <\/em>\u2286 <em>PERSONS<\/em>), ranges of the attributes (e.g., <em>Month <\/em>between 1&nbsp; and 12), compulsory (not null) attribute values (e.g., <em>BirthDate <\/em>compulsory), minimal&nbsp; uniqueness of attributes (e.g., <em>SSN <\/em>unique) and attribute concatenations (e.g., <em>Room <\/em>\u2022 <em>Weekday&nbsp; <\/em>\u2022 <em>StartHour <\/em>unique), and other restriction types (e.g., \u201cno teacher may be simultaneously&nbsp; present in two classrooms\u201d).&nbsp;<\/p>\n\n\n\n<p>An E-RD may be single, i.e., consisting only of an entity or relationship type set and its&nbsp; attributes, or structural, i.e., containing any number of sets, the structural functions (i.e., binary&nbsp; functional relationships) relating them, and no attributes. The single ones for relationship-type&nbsp; sets also contain all the sets over which the relationship is defined.&nbsp;<\/p>\n\n\n\n<p>2&nbsp;<\/p>\n\n\n\n<p><em>MatBase <\/em>[7, 8] is our intelligent data and knowledge base management system prototype,&nbsp; based on both (E)MDM, E-RDM, and RDM. It includes 3 graphic user interfaces (GUI), one&nbsp; for each data model, and automatically translates between them, generates corresponding sa&nbsp; GUIs and code for enforcing a vast majority of the (E)MDM constraint types.&nbsp;<\/p>\n\n\n\n<p>In our previously published paper [9], we presented and discussed the forward <em>MatBase&nbsp; <\/em>algorithm for translating E-R data models into (E)MDM schemes. The algorithm presented in&nbsp; this paper is its dual, a reverse engineering type one. Its necessity arises from the following&nbsp; couple of reasons:&nbsp;<\/p>\n\n\n\n<p>\u2713 Reflecting updates of a(n) (E)MDM schema performed after obtaining it from an E-R&nbsp; data model.&nbsp;<\/p>\n\n\n\n<p>\u2713 Extracting only an E-R data model subset.&nbsp;<\/p>\n\n\n\n<p>The algorithm has two optional input parameters: an object set name of the current db, and&nbsp; a natural radius. If the first one is not null and the radius is either null or 0, then the algorithm&nbsp; outputs the E-R data model of the corresponding object set (whose E-RD is a single one); for&nbsp; any other natural value <em>n <\/em>of the radius, it outputs the E-R data sub-model centered in the desired&nbsp; object set and having radius at most <em>n <\/em>(i.e., whose E-RD is a structural one having length at&nbsp; most <em>n <\/em>for at least one path starting from the desired object set); if the first parameter is null,&nbsp; then it outputs the whole db E-R data model (and the radius is ignored if it is not null).&nbsp;&nbsp;<\/p>\n\n\n\n<p>After the literature review, the third Section introduces and characterizes the pseudocode&nbsp; algorithm used by <em>MatBase <\/em>to translate (E)MDM schemes into E-R data models, then presents&nbsp; and discusses the results of applying this algorithm to an (E)MDM scheme from [10, 11]. The&nbsp; paper ends with conclusions, recommendations, and a reference list.&nbsp;&nbsp;<\/p>\n\n\n\n<p>2. Related work&nbsp;<\/p>\n\n\n\n<p>Only <em>MatBase <\/em>manages (E)MDM schemes.<\/p>\n\n\n\n<p>Quest has over 30 years of its <em>erwin Data Modeler<\/em>[12] success. For example, it may reverse&nbsp; engineer both relational (e.g., MS SQL Server, Oracle Database, IBM Db2, Sybase SQL&nbsp; Anywhere, SQLite) and noSQL (e.g., mongoDB, cassandra, MariaDB, neo4j) schemas into&nbsp; corresponding E-RDs.&nbsp;&nbsp;<\/p>\n\n\n\n<p>Related algorithms are, however, used by all major commercial RDBMSes for translating&nbsp; relational schemas into E-R data models-like ones.&nbsp;<\/p>\n\n\n\n<p>For example, the MS SQL Server Management Studio [13] provides a <em>Database Diagram&nbsp; <\/em>menu, part of the <em>Visual Database Tools<\/em>. You can create, update, and delete relational diagrams&nbsp; corresponding to the tables of a db. These diagrams are not \u201cstandard\u201d E-RDs but are equivalent&nbsp; to them: nodes are rectangles corresponding to underlying db tables that can be thought of as&nbsp; single E-RDs, as their attributes are listed inside them; edges are the relations between tables,&nbsp; as established by the foreign keys, so that they are equivalent to structural functions and E&nbsp;<\/p>\n\n\n\n<p>RDs. As the RDM is a syntactical one, no relationship-type nodes are present, all of them being&nbsp; of entity-type. This is consistent with our Theorem stating that the only fundamental&nbsp; mathematical relations for conceptual data modeling are the functions [14].&nbsp;<\/p>\n\n\n\n<p>Similarly, the Oracle SQL Developer provides a <em>Data Modeler <\/em>tool [15]. The IBM Db2 Data Management Console [16], which is the equivalent of both MS SQL&nbsp; Server Management Studio and Oracle SQL Developer does not provide graphical tools. They&nbsp; are available from third parties, such as Dataedo [17].&nbsp;<\/p>\n\n\n\n<p>Other related approaches to <em>MatBase <\/em>are based on business rules management (BRM) [18,&nbsp; 19] and their corresponding implemented systems (BRMS) and decision managers (e.g., [20 \u2013 22]). From this perspective, (E)MDM is also a formal BRM, and <em>MatBase <\/em>is an automatically&nbsp; code generating BRMS.<\/p>\n\n\n\n<p>3. Research Methodology&nbsp;<\/p>\n\n\n\n<p>Any (<em>E<\/em>)<em>MDM schema <\/em>[1] is a quadruple DKS = &lt;S, M, C; P&gt;, where S is a finite non empty <em>poset of sets <\/em>ordered by inclusion, M is a finite non-empty <em>set of mappings <\/em>defined on&nbsp; and taking values from the sets of S, C is a finite non-empty <em>set of constraints <\/em>(i.e. closed Horn&nbsp; clauses of the first-order predicate logic with equality) over sets in S and\/or mappings in M ,&nbsp; and P is a finite set of <em>Datalog<\/em>\u00ac <em>programs<\/em>, also over sets in S and mappings in M. Whenever&nbsp; P is empty, DKS is a <em>db scheme<\/em>, otherwise it is a <em>knowledge base one<\/em>. In the context of this&nbsp; paper, we are only interested in db schemes.&nbsp;<\/p>\n\n\n\n<p>(S, \u2286) is a <em>poset of sets<\/em>, with S = \u03a9 \u2295 V \u2295 *S \u2295 SysS, where \u03a9 = E \u2295 R (the non-empty&nbsp; collection of <em>object sets<\/em>), where E is a non-empty collection of atomic <em>entity-type sets <\/em>(e.g.,&nbsp; <em>PEOPLE<\/em>, <em>COUNTRIES<\/em>, <em>PRODUCTS<\/em>), R is a collection of <em>relationship-type sets <\/em>(e.g.,&nbsp; <em>NEIGHBOUR_ COUNTRIES <\/em>\u2282 <em>COUNTRIES <\/em>\u00d7 <em>COUNTRIES<\/em>, <em>STOCKS <\/em>\u2282&nbsp;<\/p>\n\n\n\n<p><em>PRODUCTS<\/em>\u00d7<em>WAREHOUSES<\/em>); V is a non-empty collection of <em>value sets <\/em>(e.g., <em>SEXES <\/em>=&nbsp; {\u201cF\u201d,\u201dM\u201d}, [0,16] \u2282 NAT(2), ASCII(32) \u2282 ASCII(<em>n<\/em>), [1\/1\/100, <em>Today<\/em>()] \u2282 DATETIME, with&nbsp; NAT(<em>n<\/em>) being the subset of naturals of at most <em>n <\/em>digits, ASCII(<em>n<\/em>) the subset of the freely&nbsp; generated monoid over the ASCII alphabet only including strings of maximum length <em>n<\/em>, etc.);&nbsp; *S is a collection of <em>computed sets <\/em>(e.g., <em>MALES<\/em>, <em>FEMALES<\/em>, <em>UNPAID_BILLS<\/em>), and SysS is a&nbsp; collection of <em>system sets <\/em>(e.g., \u2205 (the empty set), NULLS (the distinguished countable set of&nbsp; <em>null values<\/em>), BOOLE = {<em>true<\/em>, <em>false<\/em>}, NAT(<em>n<\/em>), ASCII(<em>n<\/em>), DATETIME (the set of date and time&nbsp; values)).&nbsp;<\/p>\n\n\n\n<p>In RDM schemata, generally, the object sets are tables, the computed sets are views&nbsp; (queries), the system sets are corresponding db management system (RDBMS) data types, and&nbsp; the value sets are their needed subsets.&nbsp;&nbsp;<\/p>\n\n\n\n<p>The <em>set of mappings <\/em>(<em>functions<\/em>) is M = A \u2295 F \u2295 *M \u2295 SysM, where A \u2282 Hom(S \u2013 SysS&nbsp; \u2295V, V) is the non-empty <em>set of attributes<\/em>(e.g., <em>x <\/em>: <em>PEOPLE <\/em>\u2194 NAT(10), <em>FirstName <\/em>: <em>PEOPLE<\/em><\/p>\n\n\n\n<p>5&nbsp;<\/p>\n\n\n\n<p>\u2192 ASCII(64), <em>BirthDate <\/em>: PEOPLE \u2192 [1\/1\/-6000, <em>Today<\/em>()], <em>Sex <\/em>: <em>PEOPLE <\/em>\u2192 {\u201cF\u201d, \u201cM\u201d),&nbsp; <em>Amount <\/em>: <em>UNPAID_BILLS <\/em>\u2192 (0, 100000], where \u2194 denotes injections (one-to-one functions)&nbsp; and <em>x <\/em>is our notation for <em>object identifiers<\/em>, i.e., functions to be implemented as autonumber&nbsp; surrogate primary keys); F \u2282 Hom(S \u2013 SysS \u2295V, S \u2013 SysS \u2295 V) is the non-empty set of&nbsp; <em>structural functions <\/em>(e.g., <em>BirthPlace <\/em>: <em>PEOPLE <\/em>\u2192 <em>CITIES<\/em>, <em>Capital <\/em>: <em>COUNTRIES <\/em>\u2194 <em>CITIES<\/em>); *M is the set of <em>computed mappings <\/em>(e.g., <em>BirthCountry <\/em>= <em>Country <\/em>\u00b0 <em>BirthPlace <\/em>:&nbsp; <em>PEOPLE <\/em>\u2192 <em>COUNTRIES<\/em>, <em>Mother <\/em>\u2022 <em>Father <\/em>: <em>PEOPLE <\/em>\u2192 (<em>PEOPLE <\/em>\u222aNULLS)<sup>2<\/sup>), and SysM&nbsp; is the set of <em>system mappings <\/em>(e.g., <strong>1<\/strong><em>S <\/em>(the unity function of a set <em>S<\/em>), <em>card<\/em>(<em>S<\/em>) (the cardinal of a&nbsp; set <em>S<\/em>), <em>Im<\/em>(<em>f <\/em>) (the image of a function <em>f<\/em>, i.e., the set of the values it takes), <em>dom<\/em>(<em>f<\/em>) and <em>codom<\/em>(<em>f<\/em>)&nbsp; (the domain and codomain of <em>f<\/em>, respectively), <em>isNull<\/em>(<em>x<\/em>,<em>y<\/em>) (which returns <em>x <\/em>if it is not null, and&nbsp; <em>y <\/em>otherwise)).&nbsp;<\/p>\n\n\n\n<p>In RDM schemata, the attributes, structural functions, and computed mappings are&nbsp; implemented as table or\/and view (query) columns, with structural functions being foreign&nbsp; keys.&nbsp;<\/p>\n\n\n\n<p>The <em>set of constraints <\/em>is C = SC \u2295 MC \u2295 OC \u2295 SysC, where the <em>set constraints <\/em>SC contains&nbsp; both general ones (e.g., inclusion, equality, disjointness) and dyadic relation ones (e.g.,&nbsp; reflexivity, symmetry, transitivity); the <em>mapping constraints <\/em>MC contains the general ones&nbsp; (e.g., totality, one-to-oneness, ontoness), dyadic-type self-map ones, general mapping products&nbsp; ones (e.g., minimal one-to-oneness, variable geometry keys and their subkeys, existence),&nbsp; dyadic-type homogeneous binary product ones, function diagram ones (e.g., commutativity,&nbsp; anti-commutativity, representative systems); the set OC of <em>object constraints <\/em>contains any&nbsp; other closed Horn clauses not among the above, and the <em>system constraints <\/em>SysC includes all&nbsp; needed mathematical constraints (e.g., <em>card<\/em>(\u2205) = 0, \u2205 \u2286 <em>S<\/em>, \u2205 \u2229 <em>S <\/em>= \u2205, <em>S <\/em>\u2229 <em>S <\/em>= <em>S <\/em>\u222a <em>S <\/em>= <em>S <\/em>,&nbsp; \u2200<em>S<\/em>\u2208S).<\/p>\n\n\n\n<p>Constraints are not absolute, but relative to the corresponding subuniverses: for example,&nbsp; constraint <em>C<\/em>1 from subsection 3.2 goes not generally hold (e.g., there are several cities called&nbsp; \u201cParis\u201d in the U.S.).&nbsp;&nbsp;<\/p>\n\n\n\n<p>Structural E-RDs are directed graphs having as nodes any type of sets except for the value type ones, and structural functions as edges. Our version of E-RDs [4] uses arrows (i.e., the&nbsp; standard mathematical convention for mappings) instead of diamonds for any binary functional&nbsp; relationship.&nbsp;<\/p>\n\n\n\n<p>In (E)MDM, as a shorthand, the domain of attributes may be omitted if they are listed&nbsp; immediately after their domain set name, and one-to-one mappings use double arrows (e.g.,&nbsp; see attribute <em>Country <\/em>\u2194 ASCII(255) from subsection 3.2).&nbsp;<\/p>\n\n\n\n<p>The <em>complexity of an algorithm <\/em>is denoted by <em>O<\/em>(<em>e<\/em>), where <em>e <\/em>is an algebraic expression and&nbsp; means that the algorithm never loops infinitely and ends in a number of steps that is a multiple&nbsp; of <em>e<\/em>. Generally, an algorithm is <em>sound <\/em>if it returns only true answers, <em>complete <\/em>if it accepts any&nbsp; valid inputs, and <em>optimal <\/em>(<em>efficient<\/em>) if it performs in the minimal number of steps possible for&nbsp; any input. Moreover, we say that an algorithm is <em>semi-optimal <\/em>when, even if it visits more than&nbsp; once an object, it processes any object only once.&nbsp;&nbsp;<\/p>\n\n\n\n<p>In our context, <em>soundness <\/em>means that all object and computed sets are translated into same&nbsp; type of sets (i.e., rectangles or diamonds, respectively), attributes into ellipses, structural&nbsp; functions into arrows (all of the above being dotted for computed objects), constraints into&nbsp; restrictions, and comments into informal description texts, while <em>completeness <\/em>means that all&nbsp; valid (E)MDM schemes are correspondingly translated.&nbsp;<\/p>\n\n\n\n<p>In this paper, \u201cmapping\u201d and \u201cfunction\u201d are used interchangeably. Mapping totality is&nbsp; translated into RDM by a corresponding not null constraint.<\/p>\n\n\n\n<p>4. The <em>REA<\/em>2 Algorithm&nbsp;<\/p>\n\n\n\n<p>The reverse engineering pseudocode algorithm <em>REA<\/em>2 used by <em>MatBase <\/em>for translating&nbsp; (E)MDM schemes into E-R data models is shown in Figures 1 to 10. The dependencies between&nbsp; its 10 methods are presented in Figure 11.&nbsp;<\/p>\n\n\n\n<p>Obviously, value-type sets are not figured in E-RDs: only object or computed ones (which&nbsp; are drawn in dotted lines) are.&nbsp;<\/p>\n\n\n\n<p>5. Results: two reverse engineering examples&nbsp;<\/p>\n\n\n\n<p>Here is an example of an (E)MDM schema \u2013 a subset of the <em>GENEALOGIES <\/em>sub-universe&nbsp; studied in [10, 11]:&nbsp;<\/p>\n\n\n\n<p><strong><em>COUNTRIES&nbsp;<\/em><\/strong><\/p>\n\n\n\n<p><em>x <\/em>\u2194 NAT(3) total&nbsp;<\/p>\n\n\n\n<p><em>Country <\/em>\u2194 ASCII(255) total (There may not be 2 countries having same name.)<\/p>\n\n\n\n<p><strong><em>CITIES&nbsp;<\/em><\/strong><\/p>\n\n\n\n<p><em>x <\/em>\u2194 NAT(6) total&nbsp;<\/p>\n\n\n\n<p><em>City <\/em>\u2192 ASCII(255) total&nbsp;<\/p>\n\n\n\n<p><em>Country <\/em>: <em>CITIES <\/em>\u2192 <em>COUNTRIES <\/em>total&nbsp;<\/p>\n\n\n\n<p><em>Capital <\/em>: <em>COUNTRIES <\/em>\u2194 <em>CITIES <\/em>(No city may simultaneously be the capital of 2 countries.)<\/p>\n\n\n\n<p><em>C<\/em>1: <em>City <\/em>\u2022 <em>Country <\/em>key (There may not be 2 cities with a same name in a same country.) <em>C<\/em>2: <em>Country <\/em>\u00b0 <em>Capital <\/em>reflexive (The capital city of any country must belong to that country.)&nbsp;<\/p>\n\n\n\n<p><strong><em>DYNASTIES&nbsp;&nbsp;<\/em><\/strong><\/p>\n\n\n\n<p><em>x <\/em>\u2194 NAT(8) total&nbsp;<\/p>\n\n\n\n<p><em>Dynasty <\/em>\u2194 ASCII(255) total (There may not be 2 dynasties having same name.) <em>Country <\/em>: <em>DYNASTIES <\/em>\u2192 <em>COUNTRIES <\/em>total<\/p>\n\n\n\n<p><strong><em>TITLES&nbsp;<\/em><\/strong><\/p>\n\n\n\n<p><em>x <\/em>\u2194 NAT(2) total&nbsp;<\/p>\n\n\n\n<p><em>Title <\/em>\u2194 ASCII(32) total (There may not be 2 titles having same name.) <strong><em>RULERS&nbsp;<\/em><\/strong><\/p>\n\n\n\n<p><em>x <\/em>\u2194 NAT(16) total&nbsp;<\/p>\n\n\n\n<p><em>Name <\/em>\u2192 ASCII(255) total&nbsp;<\/p>\n\n\n\n<p><em>Sex <\/em>\u2192 {\u2018M\u2019, \u2018F\u2019, \u2018N\u2019} total (\u2018N\u2019 is for non-persons)&nbsp;<\/p>\n\n\n\n<p><em>BirthYear <\/em>\u2192 [-6500, <em>CurrentYear<\/em>()]&nbsp;<\/p>\n\n\n\n<p><em>PassedAwayYear <\/em>\u2192 [-6500, <em>CurrentYear<\/em>()]&nbsp;<\/p>\n\n\n\n<p><em>URL <\/em>\u2192 ASCII(255)&nbsp;<\/p>\n\n\n\n<p><em>Age <\/em>= <em>isNull<\/em>(<em>PassedAwayYear<\/em>, <em>CurrentYear<\/em>()) \u2013 <em>BirthYear&nbsp;<\/em><\/p>\n\n\n\n<p><em>Mother <\/em>: <em>RULERS<\/em>\u2192 <em>RULERS <\/em>acyclic (Nobody may be his\/her maternal ancestor or&nbsp; descendant.)&nbsp;<\/p>\n\n\n\n<p><em>Father <\/em>: <em>RULERS<\/em>\u2192 <em>RULERS <\/em>acyclic (Nobody may be his\/her paternal ancestor or&nbsp; descendant.)&nbsp;<\/p>\n\n\n\n<p><em>KilledBy <\/em>: <em>RULERS<\/em>\u2192 <em>RULERS<\/em><\/p>\n\n\n\n<p><em>Dynasty <\/em>: <em>RULERS<\/em>\u2192 <em>DYNASTIES&nbsp;<\/em><\/p>\n\n\n\n<p><em>Title <\/em>: <em>RULERS<\/em>\u2192 <em>TITLES&nbsp;<\/em><\/p>\n\n\n\n<p><em>Founder <\/em>: <em>DYNASTIES <\/em>\u2194 <em>RULERS <\/em>(Nobody founds more than one dynasty.) <em>BirthPlace <\/em>: <em>RULERS<\/em>\u2192 <em>CITIES&nbsp;<\/em><\/p>\n\n\n\n<p><em>Nationality <\/em>: <em>RULERS<\/em>\u2192 <em>COUNTRIES&nbsp;<\/em><\/p>\n\n\n\n<p><em>PassedAwayPlace <\/em>: <em>RULERS <\/em>\u2192 <em>CITIES&nbsp;<\/em><\/p>\n\n\n\n<p><em>C<\/em>3: <em>Name <\/em>\u2022 <em>Dynasty <\/em>\u2022 <em>BirthYear <\/em>key (There may not be two persons of a same dynasty born in&nbsp; a same year and having a same name.)&nbsp;<\/p>\n\n\n\n<p><em>C<\/em>4: <em>Dynasty <\/em>\u00b0 <em>Founder <\/em>reflexive (The founder of any dynasty must belong to that dynasty.) <em>C<\/em>5: (\u2200<em>x<\/em>\u2208<em>RULERS<\/em>)(<em>Dynasty<\/em>(<em>x<\/em>) \u2209 NULLS \u2227 <em>Founder<\/em>(<em>Dynasty<\/em>(<em>x<\/em>)) \u2209 NULLS \u2227 <em>BirthYear<\/em>(<em>Founder<\/em>(<em>Dynasty<\/em>(<em>x<\/em>))) \u2209 NULLS \u21d2 <em>PassedAwayYear<\/em>(<em>x<\/em>) \u2208 NULLS \u2228 <em>PassedAwayYear<\/em>(<em>x<\/em>) &gt; <em>BirthYear<\/em>(<em>Founder<\/em>(<em>Dynasty<\/em>(<em>x<\/em>))))&nbsp;&nbsp;<\/p>\n\n\n\n<p>(Nobody may belong to a dynasty that was founded after his\/her death). <em>C<\/em>6: (\u2200<em>x<\/em>\u2208<em>RULERS<\/em>)(0 \u2264 <em>Age<\/em>(<em>x<\/em>) \u2264 140) (Anybody\u2019s age must be a natural at most equal to 140.) <em>C<\/em>7: (\u2200<em>x<\/em>\u2208<em>RULERS<\/em>)(<em>Sex<\/em>(<em>Mother<\/em>(<em>x<\/em>)) = \u2018F\u2019) (Mothers\u2019 sex must be \u2018F\u2019.)&nbsp;&nbsp;<\/p>\n\n\n\n<p><em>C<\/em>8: (\u2200<em>x<\/em>\u2208<em>RULERS<\/em>)(<em>Sex<\/em>(<em>Father<\/em>(<em>x<\/em>)) = \u2018M\u2019) (Fathers\u2019 sex must be \u2018M\u2019.)&nbsp;&nbsp;<\/p>\n\n\n\n<p><em>C<\/em>9: (\u2200<em>x<\/em>\u2208<em>RULERS<\/em>)(<em>Sex<\/em>(<em>x<\/em>) = \u2018N\u2019 \u21d2 <em>Mother<\/em>(<em>x<\/em>) \u2208 NULLS \u2227 <em>Father<\/em>(<em>x<\/em>) \u2208 NULLS \u2227 <em>Dynasty<\/em>(<em>x<\/em>)&nbsp; \u2208 NULLS \u2227 <em>KilledBy<\/em>(<em>x<\/em>) \u2208 NULLS) (Non-persons may not have parents or killers or&nbsp; belong to dynasties.)&nbsp;<\/p>\n\n\n\n<p><em>C<\/em>10: (\u2200<em>x,y<\/em>\u2208<em>RULERS<\/em>)(<em>x <\/em>\u2260 <em>y <\/em>\u2227 <em>Mother<\/em>(<em>x<\/em>) = <em>Mother<\/em>(<em>y<\/em>) \u21d2 <em>Name<\/em>(<em>x<\/em>) \u2260 <em>Name<\/em>(<em>y<\/em>)) (No mother gives&nbsp; a same name to 2 of her children.)&nbsp;<\/p>\n\n\n\n<p><em>C<\/em>11: (\u2200<em>x,y<\/em>\u2208<em>RULERS<\/em>)(<em>x <\/em>\u2260 <em>y <\/em>\u2227 <em>Father<\/em>(<em>x<\/em>) = <em>Father<\/em>(<em>y<\/em>) \u21d2 <em>Name<\/em>(<em>x<\/em>) \u2260 <em>Name<\/em>(<em>y<\/em>)) (No father gives&nbsp; a same name to 2 of his children.)&nbsp;<\/p>\n\n\n\n<p><em>C<\/em>12: (\u2200<em>x<\/em>\u2208<em>RULERS<\/em>)(<em>BirthYear<\/em>(<em>x<\/em>) \u2209 NULLS \u2227 <em>Mother<\/em>(<em>x<\/em>) \u2209 NULLS \u2227 <em>BirthYear<\/em>(<em>Mother<\/em>(<em>x<\/em>))&nbsp;<\/p>\n\n\n\n<p>\u2209 NULLS \u21d2 5 \u2264 <em>BirthYear<\/em>(<em>x<\/em>) \u2013 <em>BirthYear<\/em>(<em>Mother<\/em>(<em>x<\/em>)) \u2264 75 \u2227&nbsp;<\/p>\n\n\n\n<p>(<em>PassedAwayYear<\/em>(<em>Mother<\/em>(<em>x<\/em>)) \u2209 NULLS \u21d2 (<em>BirthYear<\/em>(<em>x<\/em>) \u2264 <em>PassedAwayYear<\/em>(<em>Mother<\/em>(<em>x<\/em>))))&nbsp; (Women may give birth only between 5 and 75 years, and before passing away.) <em>C<\/em>13: (\u2200<em>x<\/em>\u2208<em>RULERS<\/em>)(<em>BirthYear<\/em>(<em>x<\/em>) \u2209 NULLS \u2227 <em>Father<\/em>(<em>x<\/em>) \u2209 NULLS \u2227 <em>BirthYear<\/em>(<em>Father<\/em>(<em>x<\/em>)) \u2209 NULLS \u21d2 9 \u2264 <em>BirthYear<\/em>(<em>x<\/em>) \u2013 <em>BirthYear<\/em>(<em>Father<\/em>(<em>x<\/em>)) \u2264 100 \u2227 (<em>PassedAwayYear<\/em>(<em>Father<\/em>(<em>x<\/em>))&nbsp; \u2209 NULLS \u21d2 (<em>BirthYear<\/em>(<em>x<\/em>) \u2264 <em>PassedAwayYear<\/em>(<em>Father<\/em>(<em>x<\/em>)) + 1)) (Men may have children&nbsp; only between 9 and 100 years, and at most one year after passing away.) <em>C<\/em>14: (\u2200<em>x<\/em>\u2208<em>RULERS<\/em>)(<em>PassedAwayYear<\/em>(<em>x<\/em>) \u2209 NULLS \u2227 <em>KilledBy<\/em>(<em>x<\/em>) \u2209 NULLS \u2227 <em>BirthYear<\/em>(<em>KilledBy<\/em>(<em>x<\/em>)) \u2209 NULLS \u21d2 <em>BirthYear<\/em>(<em>KilledBy<\/em>(<em>x<\/em>)) + 3 \u2264 <em>PassedAwayYear<\/em>(<em>x<\/em>) \u2264 <em>isNull<\/em>(<em>PassedAwayYear<\/em>(<em>KilledBy<\/em>(<em>x<\/em>)), <em>BirthYear<\/em>(<em>KilledBy<\/em>(<em>x<\/em>)) + 140)) (Any killer of a&nbsp; person must have been alive and at least 3 years old when his\/her victim was killed.) <strong><em>MARRIAGES&nbsp;<\/em><\/strong><\/p>\n\n\n\n<p><em>x <\/em>\u2194 NAT(16) total&nbsp;<\/p>\n\n\n\n<p><em>MarriageYear <\/em>\u2192 [-6500, <em>CurrentYear<\/em>()]&nbsp;<\/p>\n\n\n\n<p><em>DivorceYear <\/em>\u2192 [-6500, <em>CurrentYear<\/em>()]&nbsp;<\/p>\n\n\n\n<p><em>Husband <\/em>: <em>MARRIAGES <\/em>\u2192 <em>RULERS&nbsp;<\/em><\/p>\n\n\n\n<p><em>Wife <\/em>: <em>MARRIAGES <\/em>\u2192 <em>RULERS&nbsp;<\/em><\/p>\n\n\n\n<p><em>C<\/em>15: <em>Husband <\/em>\u2022 <em>Wife <\/em>\u2022 <em>MarriageYear <\/em>key (Nobody may marry a same person twice in a same&nbsp; year.)&nbsp;<\/p>\n\n\n\n<p><em>C<\/em>16: <em>Husband <\/em>\u2022 <em>Wife <\/em>\u2022 <em>DivorceYear <\/em>key (Nobody may divorce a same person twice in a same&nbsp; year.)&nbsp;<\/p>\n\n\n\n<p><em>C<\/em>17: (\u2200<em>x<\/em>\u2208<em>MARRIAGES<\/em>)(<em>MarriageYear<\/em>(<em>x<\/em>) \u2209 NULLS \u21d2 <em>DivorceYear<\/em>(<em>x<\/em>) \u2209 NULLS \u2228 <em>DivorceYear<\/em>(<em>x<\/em>) \u2265 <em>MarriageYear<\/em>(<em>x<\/em>)) (Nobody may divorce somebody before marrying&nbsp; him\/her.)<\/p>\n\n\n\n<p><em>C<\/em>18: (\u2200<em>x<\/em>\u2208<em>MARRIAGES<\/em>)(<em>Sex<\/em>(<em>Wife<\/em>(<em>x<\/em>)) = \u2018F\u2019) (Wives\u2019 sex must be \u2018F\u2019.)&nbsp;&nbsp;<\/p>\n\n\n\n<p><em>C<\/em>19: (\u2200<em>x<\/em>\u2208<em>MARRIAGES<\/em>)(<em>Sex<\/em>(<em>Husband<\/em>(<em>x<\/em>)) = \u2018M\u2019) (Husbands\u2019 sex must be \u2018M\u2019.)&nbsp; <em>C<\/em>20: (\u2200<em>x<\/em>\u2208<em>MARRIAGES<\/em>)(<em>MarriageYear<\/em>(<em>x<\/em>) \u2209 NULLS \u21d2 ((<em>BirthYear<\/em>(<em>Husband<\/em>(<em>x<\/em>)) \u2208 NULLS&nbsp; \u2228 <em>BirthYear<\/em>(<em>Husband<\/em>(<em>x<\/em>)) \u2264 <em>MarriageYear<\/em>(<em>x<\/em>)) \u2227 (<em>PassedAwayYear<\/em>(<em>Husband<\/em>(<em>x<\/em>)) \u2208 NULLS&nbsp; \u2228 <em>PassedAwayYear<\/em>(<em>Husband<\/em>(<em>x<\/em>)) \u2265 <em>MarriageYear<\/em>(<em>x<\/em>))) \u2227 (<em>BirthYear<\/em>(<em>Wife<\/em>(<em>x<\/em>)) \u2208 NULLS \u2228 <em>BirthYear<\/em>(<em>Wife<\/em>(<em>x<\/em>)) \u2264 <em>MarriageYear<\/em>(<em>x<\/em>)) \u2227 (<em>PassedAwayYear<\/em>(<em>Wife<\/em>(<em>x<\/em>)) \u2208 NULLS \u2228 <em>PassedAwayYear<\/em>(<em>Wife<\/em>(<em>x<\/em>)) \u2265 <em>MarriageYear<\/em>(<em>x<\/em>)))) (Nobody may marry before being born or&nbsp; after death.)&nbsp;<\/p>\n\n\n\n<p><em>C<\/em>21: (\u2200<em>x<\/em>\u2208<em>MARRIAGES<\/em>)(<em>DivorceYear<\/em>(<em>x<\/em>) \u2209 NULLS \u21d2 ((<em>BirthYear<\/em>(<em>Husband<\/em>(<em>x<\/em>)) \u2208 NULLS \u2228 <em>BirthYear<\/em>(<em>Husband<\/em>(<em>x<\/em>)) \u2264 <em>DivorceYear<\/em>(<em>x<\/em>)) \u2227 (<em>PassedAwayYear <\/em>(<em>Husband<\/em>(<em>x<\/em>)) \u2208 NULLS \u2228 <em>PassedAwayYear<\/em>(<em>Husband<\/em>(<em>x<\/em>)) \u2265 <em>DivorceYear <\/em>(<em>x<\/em>))) \u2227 (<em>BirthYear<\/em>(<em>Wife<\/em>(<em>x<\/em>)) \u2208 NULLS \u2228 <em>BirthYear<\/em>(<em>Wife<\/em>(<em>x<\/em>)) \u2264 <em>DivorceYear<\/em>(<em>x<\/em>)) \u2227 (<em>PassedAwayYear<\/em>(<em>Wife<\/em>(<em>x<\/em>)) \u2208 NULLS \u2228 <em>PassedAwayYear<\/em>(<em>Wife<\/em>(<em>x<\/em>)) \u2265 <em>DivorceYear<\/em>(<em>x<\/em>)))) (Nobody may divorce before being born or&nbsp; after death.)&nbsp;<\/p>\n\n\n\n<p><strong><em>REIGNS&nbsp;<\/em><\/strong><\/p>\n\n\n\n<p><em>x <\/em>\u2194 NAT(20) total&nbsp;<\/p>\n\n\n\n<p><em>FromY <\/em>\u2192 [-6500, <em>CurrentYear<\/em>()] total&nbsp;<\/p>\n\n\n\n<p><em>ToY <\/em>\u2192 [-6500, <em>CurrentYear<\/em>()]&nbsp;<\/p>\n\n\n\n<p><em>Ruler <\/em>: <em>REIGNS <\/em>\u2192 <em>RULERS <\/em>total&nbsp;<\/p>\n\n\n\n<p><em>Country <\/em>: <em>REIGNS <\/em>\u2192 <em>COUNTRIES <\/em>total&nbsp;<\/p>\n\n\n\n<p><em>Title <\/em>: <em>RULERS<\/em>\u2192 <em>TITLES&nbsp;<\/em><\/p>\n\n\n\n<p><em>C<\/em>22: <em>Ruler <\/em>\u2022 <em>Country <\/em>\u2022 <em>FromY <\/em>key (It does not make sense to store twice that a ruler began&nbsp; ruling a country during a year.)&nbsp;<\/p>\n\n\n\n<p><em>C<\/em>23: <em>Ruler <\/em>\u2022 <em>Country <\/em>\u2022 <em>ToY <\/em>key (It does not make sense to store twice that a ruler ended ruling&nbsp;<\/p>\n\n\n\n<p>a country during a year.)&nbsp;<\/p>\n\n\n\n<p><em>C<\/em>24: (\u2200<em>x<\/em>\u2208<em>REIGNS<\/em>)(<em>ToY<\/em>(<em>x<\/em>) \u2208 NULLS \u2228 <em>ToY<\/em>(<em>x<\/em>) \u2265 <em>FromY<\/em>(<em>x<\/em>)) (No reign may end before&nbsp; starting.)&nbsp;<\/p>\n\n\n\n<p><em>C<\/em>25: (\u2200<em>x<\/em>\u2208<em>REIGNS<\/em>)((<em>BirthYear<\/em>(<em>Ruler<\/em>(<em>x<\/em>)) \u2209 NULLS \u21d2 <em>BirthYear<\/em>(<em>Ruler<\/em>(<em>x<\/em>)) \u2264 <em>FromY<\/em>(<em>x<\/em>)) \u2227 (<em>PassedAwayYear<\/em>(<em>Ruler<\/em>(<em>x<\/em>)) \u2209 NULLS \u21d2 <em>ToY<\/em>(<em>x<\/em>) \u2209 NULLS \u2227 <em>PassedAwayYear<\/em>(<em>Ruler<\/em>(<em>x<\/em>))&nbsp; \u2265 <em>ToY<\/em>(<em>x<\/em>)) (Nobody may reign before being born or after death.)&nbsp;&nbsp;<\/p>\n\n\n\n<p><em>C<\/em>26: (\u2200<em>x,y<\/em>\u2208<em>REIGNS<\/em>)(<em>x <\/em>\u2260 <em>y <\/em>\u2227 <em>Country<\/em>(<em>x<\/em>) = <em>Country<\/em>(<em>y<\/em>) \u2227 (<em>FromY<\/em>(<em>y<\/em>) \u2265 <em>FromY<\/em>(<em>x<\/em>) \u2227 <em>FromY<\/em>(<em>y<\/em>) \u2264 <em>isNull<\/em>(<em>ToY<\/em>(<em>x<\/em>), <em>CurrentYear<\/em>() \u2228 <em>FromY<\/em>(<em>x<\/em>) \u2265 <em>FromY<\/em>(<em>y<\/em>) \u2227 <em>FromY<\/em>(<em>x<\/em>) \u2264 <em>isNull<\/em>(<em>ToY<\/em>(<em>y<\/em>),&nbsp; <em>CurrentYear<\/em>()) \u21d2 (<em>Father<\/em>(<em>Ruler<\/em>(<em>y<\/em>)) = <em>Ruler<\/em>(<em>x<\/em>)) \u2228 <em>Father<\/em>(<em>Ruler<\/em>(<em>x<\/em>)) = <em>Ruler<\/em>(<em>y<\/em>) \u2228 <em>Mother<\/em>(<em>Ruler<\/em>(<em>y<\/em>)) = <em>Ruler<\/em>(<em>x<\/em>)) \u2228 <em>Mother<\/em>(<em>Ruler<\/em>(<em>x<\/em>)) = <em>Ruler<\/em>(<em>y<\/em>))) \u2228 (\u2203<em>z<\/em>\u2208<em>MARRIAGES<\/em>) (<em>Husband<\/em>(<em>z<\/em>) = <em>Ruler<\/em>(<em>x<\/em>) \u2227 <em>Wife<\/em>(<em>z<\/em>) = <em>Ruler<\/em>(<em>y<\/em>) \u2228 <em>Husband<\/em>(<em>z<\/em>) = <em>Ruler<\/em>(<em>y<\/em>) \u2227 <em>Wife<\/em>(<em>z<\/em>) = <em>Ruler<\/em>(<em>x<\/em>))) (No country may be simultaneously ruled by 2 persons, except for cases where the two&nbsp; were married or parent and child.)&nbsp;<\/p>\n\n\n\n<p>Figure 12 presents the corresponding single E-RD obtained by applying algorithm <em>REA<\/em>2&nbsp; to this (E)MDM schema with parameter values <em>S <\/em>= \u201cRULERS\u201d and <em>r <\/em>= 0 (in fact, the self-maps&nbsp; <em>Mother<\/em>, <em>Father <\/em>and <em>KilledBy <\/em>are not generated for this E-RD, but for the one in Figure 13: we&nbsp; moved them here in this paper as Figure 13 would otherwise become too complicated).&nbsp;<\/p>\n\n\n\n<p>The corresponding generated Restriction Set is the following:&nbsp;<\/p>\n\n\n\n<p>a. <em>max<\/em>(<em>card<\/em>(<em>RULERS<\/em>) = 10<sup>16<\/sup>&nbsp;<\/p>\n\n\n\n<p>b. <em>Data ranges<\/em>:&nbsp;&nbsp;<\/p>\n\n\n\n<p><em>Name<\/em>: ASCII(255)&nbsp;&nbsp;<\/p>\n\n\n\n<p><em>Sex<\/em>: {\u2018M\u2019, \u2018F\u2019, \u2018N\u2019}&nbsp;<\/p>\n\n\n\n<p><em>BirthYear<\/em>: [-6500, <em>CurrentYear<\/em>()]&nbsp;<\/p>\n\n\n\n<p><em>PassedAwayYear<\/em>: [-6500, <em>CurrentYear<\/em>()]<\/p>\n\n\n\n<p><em>URL<\/em>: ASCII(255)&nbsp;<\/p>\n\n\n\n<p>c. <em>Compulsory data<\/em>: <em>x<\/em>, <em>Name<\/em>, <em>Sex&nbsp;<\/em><\/p>\n\n\n\n<p>d. <em>Uniqueness<\/em>:&nbsp;&nbsp;<\/p>\n\n\n\n<p><em>Name <\/em>\u2022 <em>Dynasty <\/em>\u2022 <em>BirthYear <\/em>(There may not be two persons of a same dynasty born in&nbsp; a same year and having a same name.)&nbsp;<\/p>\n\n\n\n<p><em>Founder <\/em>(Nobody founds more than one dynasty.)&nbsp;<\/p>\n\n\n\n<p>e. <em>Other types of restrictions<\/em>:&nbsp;&nbsp;<\/p>\n\n\n\n<p><em>f. Age <\/em>= <em>isNull<\/em>(<em>PassedAwayYear<\/em>, <em>CurrentYear<\/em>()) \u2013 <em>BirthYear&nbsp;<\/em><\/p>\n\n\n\n<p><em>g. Mother <\/em>acyclic (Nobody may be his\/her maternal ancestor or descendant.) h. <em>Father <\/em>acyclic (Nobody may be his\/her paternal ancestor or descendant.) i. <em>C<\/em>3 to <em>C<\/em>14 (that we do not duplicate here, to obey paper length limitations).&nbsp; The corresponding informal description is trivial: \u201cThe set of <em>RULERS <\/em>stores properties <em>x<\/em>,&nbsp;&nbsp;<\/p>\n\n\n\n<p>its object integer identifier, <em>Name<\/em>, an ASCII string of at most 255 characters, etc.\u201d.&nbsp; Figure 13 shows the structural E-RD obtained when running <em>REA<\/em>2 with <em>S <\/em>= \u201cRULERS\u201d&nbsp; and <em>r <\/em>&gt; 0 or with null values for both <em>S <\/em>and <em>r<\/em>. The corresponding restriction set for <em>RULERS <\/em>is&nbsp; exactly the one given above; for the rest of the sets, it is similar. This goes the same for the&nbsp; corresponding informal description.<\/p>\n\n\n\n<p>6. Discussion&nbsp;<\/p>\n\n\n\n<p><strong><em>Proposition&nbsp;<\/em><\/strong><\/p>\n\n\n\n<p><em>REA<\/em>2 is:&nbsp;<\/p>\n\n\n\n<p>(<em>i<\/em>) linear, having complexity O(<em>n <\/em>+ <em>a <\/em>+ <em>m <\/em>+ <em>c<\/em>), where <em>n <\/em>is the total number of the (E)MDM&nbsp; schema non-value sets, <em>a <\/em>is the total number of their attributes, <em>m <\/em>of their structural functions&nbsp; (including the roles of the relationship-type sets), and <em>c <\/em>is the total number of its constraints; (<em>ii<\/em>) sound;&nbsp;<\/p>\n\n\n\n<p>(<em>iii<\/em>) complete;&nbsp;<\/p>\n\n\n\n<p>(<em>iv<\/em>) semi-optimal.&nbsp;<\/p>\n\n\n\n<p><em>Proof&nbsp;<\/em><\/p>\n\n\n\n<p>(<em>i<\/em>) For <em>r <\/em>= 0, trivially, <em>n <\/em>\u2264 1, <em>m <\/em>= 0, while <em>a <\/em>and <em>c <\/em>are the number of attributes defined on <em>S&nbsp; <\/em>and the one of the constraints involving <em>S<\/em>, respectively (added by the only one executions of&nbsp; methods <em>addSet<\/em>, <em>addAttributes<\/em>, and <em>addFunctRestrictions<\/em>, when <em>S <\/em>is a known set; otherwise,&nbsp; they are 0 as well); for <em>S <\/em>known and <em>r <\/em>&gt; 0, the number of the corresponding non-value-type&nbsp; sets of the sub-model is <em>s <\/em>\u2264 <em>n <\/em>= <em>card<\/em>(<em>Nodes<\/em>(M)), the one of structural functions is <em>f <\/em>\u2264 <em>m <\/em>=&nbsp; <em>card<\/em>(<em>Edges<\/em>(M)), while <em>a <\/em>and <em>c <\/em>are the sums of the number of attributes defined on the sets of&nbsp; the corresponding sub-model and the sum of the constraints involving these sets, respectively;&nbsp;<\/p>\n\n\n\n<p>finally, when <em>S <\/em>is null, <em>s <\/em>= <em>n<\/em>, <em>f <\/em>=<em>m<\/em>, while <em>a <\/em>and <em>c <\/em>are the sums of the number of attributes defined&nbsp; on the sets of the corresponding (E)MDM schema and the sum of its constraints , respectively. It is very easy to verify that the only loops of <em>REA<\/em>2 and of its method <em>computeCardinal <\/em>are&nbsp; executed exactly <em>n <\/em>times, the one from method <em>addStructuralFunctions <\/em>exactly for the number&nbsp; of such functions defined on its parameter, the one from <em>addAttributes<\/em>, similarly, exactly for&nbsp; the number of such functions defined on its parameter, and the one from <em>addSet <\/em>exactly for the&nbsp; number of constraints that involve its parameter and that were not previously converted to the&nbsp; corresponding restrictions.&nbsp;&nbsp;<\/p>\n\n\n\n<p>The methods <em>otherSet<\/em>, <em>addFunctRestrictions<\/em>, <em>addRelationshipType <\/em>and <em>addEntityType&nbsp; <\/em>have no loops.&nbsp;&nbsp;<\/p>\n\n\n\n<p>Finally, the outer <em>while <\/em>loop of method <em>subModel <\/em>is executed at most <em>n <\/em>times; before its&nbsp; first execution, the <em>S_A <\/em>array is initialized with the set name <em>S <\/em>and its level 0 (in the above&nbsp; example, <em>S <\/em>= \u201cRULERS\u201d); in each iteration, its inner <em>while <\/em>loop is executed exactly the number&nbsp; of times that there are sets on the previous level; in the first iteration it is executed exactly once,&nbsp; for <em>S<\/em>; its first inner loop is executed, for each iteration, exactly the number of times the current&nbsp; set has structural functions defined on it (e.g., for \u201cRULERS\u201d, 5 times, discovering and storing&nbsp; in <em>S_A <\/em>the sets named \u201cDYNASTIES\u201d, \u201cCITIES\u201d, \u201cCOUNTRIES\u201d, and \u201cTITLES\u201d); its second&nbsp; inner loop is executed, for each iteration, exactly the number of times the current set has&nbsp; structural functions taking values from it (e.g., for \u201cRULERS\u201d, 4 times, discovering and storing&nbsp; in <em>S_A <\/em>the sets named \u201cMARRIAGES\u201d and \u201cREIGNS\u201d); as, its final loop is executed at most&nbsp; <em>n <\/em>times, method <em>subModel <\/em>might need at most 2<em>n <\/em>steps to finish.&nbsp;<\/p>\n\n\n\n<p>Consequently, <em>REA<\/em>2 never loops infinitly and is linear in the sum <em>n <\/em>+ <em>a <\/em>+ <em>m <\/em>+ <em>c<\/em>.&nbsp; (<em>ii<\/em>) As any entity-type set is translated into a rectangle, any relationship-type one into a&nbsp; diamond, any attribute into an ellipsis, any structural function into an arrow, any constraint into&nbsp; a corresponding restriction, and any comment into an informal description text, <em>REA<\/em>2 is sound.<\/p>\n\n\n\n<p>(<em>iii<\/em>) As any well-formed (E)MDM schema (i.e., only consisting of sets, mappings,&nbsp; constraints, and comments) is translated into corresponding E-R data models, <em>REA<\/em>2 is&nbsp; complete.&nbsp;<\/p>\n\n\n\n<p>(<em>iv<\/em>) For <em>S <\/em>null and <em>S <\/em>not-null but <em>r <\/em>= 0 or null, <em>REA<\/em>2 is optimal, as it reads and processes&nbsp; each non-value-type set, function, and constraint only once. For <em>S <\/em>not-null and <em>r <\/em>&gt; 0, it is only&nbsp; semi-optimal, as it processes them only once, but reads the corresponding sub-model non-value&nbsp; sets twice (once for discovering and storing them into the <em>S_A <\/em>array, and a second time to&nbsp; translate them), some of the structural functions twice as well (once as defined on the current&nbsp; set in the inner <em>while <\/em>loop and a second time as taking values from it), and each constraint the&nbsp; number of times equal to the number of sets involved. <em>Q.E.D.&nbsp;&nbsp;<\/em><\/p>\n\n\n\n<p>As it may be seen from the above example, for such small (E)MDM schemas, it is not&nbsp; optimal to ask for sub-models: all 7 object sets are discovered for <em>r <\/em>= 1, so that it would be&nbsp; simpler to ask for the complete model instead, as even this smallest sub-model is equal to the&nbsp; whole one, which can be obtained faster.&nbsp;<\/p>\n\n\n\n<p>However, for commercial dbs with hundreds of object and computed sets, this feature is&nbsp; essential, as, on one hand, updates or\/and extensions of current models are generally involving&nbsp; only a handful of related sets and, on the other, printing and analyzing the whole structural E RD for them is almost impossible.&nbsp;<\/p>\n\n\n\n<p>Please note that method <em>subModel <\/em>stops execution of its outer <em>while <\/em>as soon as no more&nbsp; sets are discovered in an iteration, which is discovered whenever at the beginning of the&nbsp; following one the variables <em>j <\/em>and <em>oldj <\/em>have same value. This means, for example, that running&nbsp; the algorithm with <em>S <\/em>= \u201cRULERS\u201d and <em>r <\/em>having any other natural value greater than 1 will stop&nbsp; exactly when the one for <em>r <\/em>= 1 stops.&nbsp;<\/p>\n\n\n\n<p>The actual implementations of <em>REA<\/em>2 in <em>MatBase <\/em>are smarter and faster than the pseudocode&nbsp; algorithm presented in subsection 3.1, by using embedded SQL over its meta-catalog. For&nbsp;<\/p>\n\n\n\n<p>example, in method <em>subModel <\/em>the <em>S_A <\/em>array is replaced by a temporary table with same name&nbsp; and the two inner loops are replaced by the execution of the following MS VBA statement (for&nbsp; the structure of the meta-catalog tables <em>SETS <\/em>and <em>FUNCTIONS<\/em>, please see [8, 23]): DoCmd.RunSQL \u201cINSERT INTO S_A SELECT SetName, \u201c &amp; i &amp; \u201c FROM SETS INNER&nbsp; JOIN FUNCTIONS ON SETS.[#S] = FUNCTIONS.Codomain WHERE SetType &lt;&gt; \u2018V\u2019 AND&nbsp; Domain IN (SELECT [#S] FROM SETS INNER JOIN S_A ON SETS.SetName = S_A.Set&nbsp; WHERE len = \u201c &amp; i \u2013 1 &amp; \u201c) AND SetName NOT IN (SELECT Set FROM S_A) UNION&nbsp; SELECT SetName, \u201c &amp; i &amp; \u201c FROM SETS INNER JOIN FUNCTIONS ON SETS.[#S] =&nbsp; FUNCTIONS. Domain WHERE Codomain IN (SELECT [#S] FROM SETS INNER JOIN&nbsp; S_A ON SETS.SetName = S_A.Set WHERE len = \u201c &amp; i \u2013 1 &amp; \u201c) AND SetName NOT IN&nbsp; (SELECT Set FROM S_A)\u201d;&nbsp;<\/p>\n\n\n\n<p>7. Conclusions and further work&nbsp;<\/p>\n\n\n\n<p>To sum up, we presented a linear, sound, complete, and semi-optimal pseudocode algorithm&nbsp; for translating E-R data models into (E)MDM schemes, used by both versions of our intelligent&nbsp; DBMS prototype <em>MatBase<\/em>. Obviously, this algorithm may be also manually used by db and\/or&nbsp; software architects.&nbsp;<\/p>\n\n\n\n<p>We provided an example of applying it to a genealogical tree sub-universe.&nbsp; We also described some powerful additional features of its actual implementations that are&nbsp; aimed at obtaining the fastest possible execution speed.&nbsp;<\/p>\n\n\n\n<p>We successfully used this algorithm for years during our classes of Advanced Database and&nbsp; Software Application Architecture and Design for M.Sc. students with both Computer Science&nbsp; Taught in English stream of the Department of Engineering in Foreign Languages from the&nbsp; Bucharest Polytechnic University and Informatics of the Department of Mathematics and&nbsp; Informatics from the Ovidius University at Constanta, Romania.<\/p>\n\n\n\n<p>We would warmly recommend using our (E)MDM during both db scheme design, db&nbsp; software application architecture, and their maintenance and extensions, as it guarantees the&nbsp; highest possible db data quality. We are convinced that even this small example from subsection&nbsp; 3.2 proves its power and elegance, as these twin fields are, in fact, applied mathematical na\u00efve&nbsp; set, relation, and function theory, plus first-order predicate calculus with equality.&nbsp;<\/p>\n\n\n\n<p>Our next paper will provide the algorithm used by <em>MatBase <\/em>to translate (E)MDM schemas&nbsp; into RDM ones and associated sets of non-relational constraints \u2013that must be enforced by the&nbsp; software applications managing those dbs\u2013, which is the next step towards guaranteeing the&nbsp; highest possible db stored data quality. For the last step, i.e., the architecture and design of db&nbsp; software applications, we would warmly recommend our db constraint-driven approach [11] .&nbsp;&nbsp;<\/p>\n\n\n\n<p>Acknowledgement&nbsp;<\/p>\n\n\n\n<p>Nobody other than its authors contributed to this paper.&nbsp;<\/p>\n\n\n\n<p>Funding Support&nbsp;<\/p>\n\n\n\n<p>This work was not sponsored by anybody.&nbsp;<\/p>\n\n\n\n<p>Ethical Statement&nbsp;<\/p>\n\n\n\n<p>This study does not contain any studies with human, or animal subjects performed by any&nbsp; of the authors.&nbsp;<\/p>\n\n\n\n<p>Conflicts of Interest&nbsp;&nbsp;<\/p>\n\n\n\n<p>The authors declare that they have no conflicts of interest to this work.<\/p>\n\n\n\n<p>References&nbsp;<\/p>\n\n\n\n<p>[1] Mancas, C. (2024). The (Elementary) Mathematical Data Model revisited. <em>Primera&nbsp; Scientific Engineering<\/em>, 5(4), 78\u201391. https:\/\/doi.org\/10.48550\/arXiv.2408.08367 [2] Chen, P.P. (1976). The entity-relationship model. Toward a unified view of data. <em>ACM&nbsp; TODS<\/em>, 1(1), 9\u201336. 10.1145\/320434.320440&nbsp;<\/p>\n\n\n\n<p>[3] Thalheim, B. (2000). <em>Entity-Relationship Modeling<\/em>: <em>Foundations of Database Technology<\/em>.&nbsp; Springer-Verlag.&nbsp;<\/p>\n\n\n\n<p>[4] Mancas, C. (2015). <em>Conceptual Data Modeling and Database Design: A Completely&nbsp; Algorithmic Approach. Volume 1: The Shortest Advisable Path. <\/em>Apple Academic Press. [5] Codd, E.F. (1970). A relational model for large shared data banks. <em>CACM <\/em>13(6), 377\u2013387.&nbsp; 10.1145\/362384.362685&nbsp;<\/p>\n\n\n\n<p>[6] Abiteboul, S., Hull, R., &amp; Vianu, V. (1995). <em>Foundation of Databases<\/em>. Addison-Wesley. [7] Mancas, C. <em>MatBase <\/em>\u2013 a tool for transparent programming while modeling data at&nbsp; conceptual levels. <em>Proc. Int. Conf. on Comp. Sci. &amp; Inf. Techn. CSITEC 2019<\/em>, Vienna,&nbsp; Austria, (2019), 15\u201327. . https:\/\/aircconline.com\/csit\/papers\/vol9\/csit91102.pdf [8] Mancas, C. (2020). <em>MatBase <\/em>metadata catalog management. <em>Acta Scientific Computer&nbsp; Sciences<\/em>, 2(4), 25\u201329. https:\/\/doi.org\/10.48550\/arXiv.2504.07243&nbsp;<\/p>\n\n\n\n<p>[9] Mancas, C. &amp; Mancas, D.C. (2025). <em>MatBase <\/em>Algorithm for Translating Entity Relationship Data Models into (Elementary) Mathematical Data Model Schemes. Primera&nbsp; Scientific Engineering 7(6), 04\u201311. https:\/\/10.56831\/PSEN-07-237&nbsp;<\/p>\n\n\n\n<p>[10] Mancas, D.C. (2023). Design and development of a database software application for&nbsp; managing genealogical trees [M.Sc. dissertation, Ovidius University at Constanta,&nbsp; Romania, Mathematics and Informatics Department].<\/p>\n\n\n\n<p>[11] Mancas, C., Serban, C., and Mancas, D.C. (2023). On Software Application Database&nbsp; Constraint-driven Design and Development. J. of Comp. Sci. Res. 5(1), 31\u201345.&nbsp; https:\/\/doi.org\/10.30564\/jcsr.v5i1.5476&nbsp;<\/p>\n\n\n\n<p>[12] Quest. (2025, November 19). erwin Data Modeler by Quest.&nbsp; https:\/\/www.quest.com\/documents\/erwin-data-modeler-datasheet-147769.pdf [13] Microsoft SQL Documentation. (2025, November 19). SQL Server Management Studio.&nbsp; https:\/\/learn.microsoft.com\/pdf?url=https%3A%2F%2Flearn.microsoft.com%2Fen us%2Fssms%2Ftoc.json&nbsp;<\/p>\n\n\n\n<p>[14] Mancas, C. &amp; Dragomir, S. On the Equivalence between Entity-Relationship and&nbsp; Functional Data Modeling. <em>Proc. IASTED Software Eng. &amp; App. SEA 2003<\/em>, Marina del&nbsp; Rey, U.S.A., (2003), 335\u2013340. https:\/\/www.actapress.com\/Abstract.aspx?paperId=14533&nbsp;<\/p>\n\n\n\n<p>[15] Oracle Corp. (2025, November 19). Oracle SQL Developer Data Modeler User\u2019s Guide.&nbsp; https:\/\/docs.oracle.com\/en\/database\/oracle\/sql-developer-data&nbsp;<\/p>\n\n\n\n<p>modeler\/24.3\/dmdug\/data-modeler-concepts-usage.html#GUID-69B12E47-6075-4471- A205-BBB04113EE24&nbsp;<\/p>\n\n\n\n<p>[16] IBM Software Hub. (2025, November 19). IBM Db2 Data Management Console.&nbsp; https:\/\/www.ibm.com\/docs\/en\/software-hub\/5.2.x?topic=services-db2-data management-console&nbsp;<\/p>\n\n\n\n<p>[17] Dataedo. (2025, November 19). Create diagram for IBM Db2 database.&nbsp; https:\/\/dataedo.com\/tutorials\/create-diagram-for-ibm-db2-database&nbsp;<\/p>\n\n\n\n<p>[18] von Halle, B. &amp; Goldberg, L. (2006). <em>The Business Rule Revolution. Running Businesses&nbsp; the Right Way<\/em>. Happy About.&nbsp;<\/p>\n\n\n\n<p>[19] Taylor, J. (2019). <em>Decision Management Systems: A Practical Guide to Using Business&nbsp; Rules and Predictive Analytics<\/em>. IBM Press.&nbsp;<\/p>\n\n\n\n<p>[20] IBM Corp. (2025, November 19). IBM Business Automation Manager Open Editions.&nbsp; https:\/\/www.ibm.com\/docs\/en\/ibamoe\/9.3.0&nbsp;<\/p>\n\n\n\n<p>[21] Red Hat Documentation. (2025, November 19). Designing your decision management&nbsp; architecture with Red Hat Decision Manager. https:\/\/docs.redhat.com\/en\/documentation\/red_hat_decision_manager\/7.13\/html\/designi ng_your_decision_management_architecture_for_red_hat_decision_manager\/index&nbsp;<\/p>\n\n\n\n<p>[22] DecisionRules.io. (2025, November 19). DecisionRules Documentation.&nbsp; https:\/\/docs.decisionrules.io\/doc\/&nbsp;[23] Mancas, C. (2025). On Enforcing Satisfiable, Coherent, and Minimal Sets of Self-map&nbsp; Constraints in <em>MatBase<\/em>. Primera Scientific Engineering 6(2), 31\u201349.&nbsp; https:\/\/10.56831\/PSEN-06-179<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. Introduction&nbsp; All subuniverses of discourse are governed by business rules (e.g., \u201dnobody may die before&nbsp; birth\u201d, \u201dnobody may get married before birth\u201d, \u201dpeople\u2019s height is between 30 and 225 cm\u201d,&nbsp; etc.). A database (db) instance is useful only if it is plausible, i.e., only if its data does not violate&nbsp; any business rule governing [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"ocean_post_layout":"","ocean_both_sidebars_style":"","ocean_both_sidebars_content_width":0,"ocean_both_sidebars_sidebars_width":0,"ocean_sidebar":"","ocean_second_sidebar":"","ocean_disable_margins":"enable","ocean_add_body_class":"","ocean_shortcode_before_top_bar":"","ocean_shortcode_after_top_bar":"","ocean_shortcode_before_header":"","ocean_shortcode_after_header":"","ocean_has_shortcode":"","ocean_shortcode_after_title":"","ocean_shortcode_before_footer_widgets":"","ocean_shortcode_after_footer_widgets":"","ocean_shortcode_before_footer_bottom":"","ocean_shortcode_after_footer_bottom":"","ocean_display_top_bar":"default","ocean_display_header":"default","ocean_header_style":"","ocean_center_header_left_menu":"","ocean_custom_header_template":"","ocean_custom_logo":0,"ocean_custom_retina_logo":0,"ocean_custom_logo_max_width":0,"ocean_custom_logo_tablet_max_width":0,"ocean_custom_logo_mobile_max_width":0,"ocean_custom_logo_max_height":0,"ocean_custom_logo_tablet_max_height":0,"ocean_custom_logo_mobile_max_height":0,"ocean_header_custom_menu":"","ocean_menu_typo_font_family":"","ocean_menu_typo_font_subset":"","ocean_menu_typo_font_size":0,"ocean_menu_typo_font_size_tablet":0,"ocean_menu_typo_font_size_mobile":0,"ocean_menu_typo_font_size_unit":"px","ocean_menu_typo_font_weight":"","ocean_menu_typo_font_weight_tablet":"","ocean_menu_typo_font_weight_mobile":"","ocean_menu_typo_transform":"","ocean_menu_typo_transform_tablet":"","ocean_menu_typo_transform_mobile":"","ocean_menu_typo_line_height":0,"ocean_menu_typo_line_height_tablet":0,"ocean_menu_typo_line_height_mobile":0,"ocean_menu_typo_line_height_unit":"","ocean_menu_typo_spacing":0,"ocean_menu_typo_spacing_tablet":0,"ocean_menu_typo_spacing_mobile":0,"ocean_menu_typo_spacing_unit":"","ocean_menu_link_color":"","ocean_menu_link_color_hover":"","ocean_menu_link_color_active":"","ocean_menu_link_background":"","ocean_menu_link_hover_background":"","ocean_menu_link_active_background":"","ocean_menu_social_links_bg":"","ocean_menu_social_hover_links_bg":"","ocean_menu_social_links_color":"","ocean_menu_social_hover_links_color":"","ocean_disable_title":"default","ocean_disable_heading":"default","ocean_post_title":"","ocean_post_subheading":"","ocean_post_title_style":"","ocean_post_title_background_color":"","ocean_post_title_background":0,"ocean_post_title_bg_image_position":"","ocean_post_title_bg_image_attachment":"","ocean_post_title_bg_image_repeat":"","ocean_post_title_bg_image_size":"","ocean_post_title_height":0,"ocean_post_title_bg_overlay":0.5,"ocean_post_title_bg_overlay_color":"","ocean_disable_breadcrumbs":"default","ocean_breadcrumbs_color":"","ocean_breadcrumbs_separator_color":"","ocean_breadcrumbs_links_color":"","ocean_breadcrumbs_links_hover_color":"","ocean_display_footer_widgets":"default","ocean_display_footer_bottom":"default","ocean_custom_footer_template":"","ocean_post_oembed":"","ocean_post_self_hosted_media":"","ocean_post_video_embed":"","ocean_link_format":"","ocean_link_format_target":"self","ocean_quote_format":"","ocean_quote_format_link":"post","ocean_gallery_link_images":"on","ocean_gallery_id":[],"footnotes":""},"categories":[23],"tags":[18,20,21,19,17],"article-archive":[22],"class_list":["post-663","post","type-post","status-publish","format-standard","hentry","category-original-research-article","tag-elementary-mathematical-data-model","tag-algorithms","tag-database-software-application-design","tag-entity-relationship-data-models","tag-matbase","article-archive-volume-4-issue-2-2025","entry"],"acf":[],"_links":{"self":[{"href":"https:\/\/academicsociety.org\/aicyberjournal\/wp-json\/wp\/v2\/posts\/663","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/academicsociety.org\/aicyberjournal\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/academicsociety.org\/aicyberjournal\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/academicsociety.org\/aicyberjournal\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/academicsociety.org\/aicyberjournal\/wp-json\/wp\/v2\/comments?post=663"}],"version-history":[{"count":2,"href":"https:\/\/academicsociety.org\/aicyberjournal\/wp-json\/wp\/v2\/posts\/663\/revisions"}],"predecessor-version":[{"id":671,"href":"https:\/\/academicsociety.org\/aicyberjournal\/wp-json\/wp\/v2\/posts\/663\/revisions\/671"}],"wp:attachment":[{"href":"https:\/\/academicsociety.org\/aicyberjournal\/wp-json\/wp\/v2\/media?parent=663"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/academicsociety.org\/aicyberjournal\/wp-json\/wp\/v2\/categories?post=663"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/academicsociety.org\/aicyberjournal\/wp-json\/wp\/v2\/tags?post=663"},{"taxonomy":"article-archive","embeddable":true,"href":"https:\/\/academicsociety.org\/aicyberjournal\/wp-json\/wp\/v2\/article-archive?post=663"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}