<?xml version="1.0" encoding="UTF-8"?>
<database-schema xmlns:rs="http://schemas.roadintranet.org/road-database-schema-1"
    xmlns:rf="http://schemas.roadintranet.org/road-faq-1" sql-schema="roaddb">
    <rf:section id="roaddb-links" title="Useful links">
        <div class="twocol">
            <div class="col leftcol">
               Header A
                <ul><li>
                    Item A
                </li></ul>
                
                Help
                <ul><li>
                </li><li>
                    <rf:iref item="setup-oxygen"/>
                </li></ul>
                
            </div>
            <div class="col rightcol">
                Main Tables and Domains
                <ul><li>
                </li><li>
                    <a href="db-sample.sql">Physical schema</a>
                </li><li>
                </li></ul>
                
                Main Views
                <ul><li>
                    <rf:iref item="rdv_view"/>
                </li><li>
                </li></ul>
            </div>
        </div>
    </rf:section>
    <rf:section id="faq-sample" title="FAQ on sample">
        <rf:item id="faq-A" title="Question A">
            <p>Some text
            </p>
            <ul><li>
                A list item
            </li><li>
            </li></ul>
        </rf:item>
        
        

        
        
        
        
        
        

    </rf:section>
    
    <rs:domains>
        These domains generate the 
        <a href="db-sample.sql">physical schema</a>
        from the
        <a href="db-sample.xml">logical schema</a>.
        
        <rf:section id="generic-domains" title="Generic ID domains">
            <rs:domain id="name-id-domain" title="Any Name ID" sql-type="varchar(100)"> Use
                <code>name-id</code> for ID fields defined by a string. Consider
                <code>name-id</code> for all IDs. Use an <rf:iref item="identity-domain"/> domain only when the ID would otherwise
                be longer than 30 characters or so. </rs:domain>
            <rs:domain id="identity-domain" title="Identity" sql-type="int">
                Need to mark the identity column with identity="yes".  Use an <i>identity-domain</i>
                for tables used for foreign-keys especially if they have a multi-column index.
                Be careful of migration and backup.  Use 'SET IDENTITY_INSERT' to preserve identity
                values.
            </rs:domain>
        </rf:section>
            <rf:section id="ID-domains" title="ID domains">
            An ID domain is a foreign key reference to a table defining the domain.
            <rs:domain id="codeline-domain" title="Codeline" same-as="name-id-domain"> A
                <i>codeline</i> is a set of files that change together, typically for building a
                product.   Converted to lower-case.</rs:domain>
            <rs:domain id="build-domain" title="Build" table="builds" column="codeline,build" same-as="name-id-domain"> A <i>build</i> is a
                build of a product.   Builds are ordered alphabetically, matching their temporal
                order.
                 Converted to lower-case. 
                Requires <code>foreign-columns="codeline,build"</code>
            </rs:domain>
                
                </rf:section>

        <rf:section id="string-domains" title="String domains">
            <rs:domain id="filepath-domain" title="File path" sql-type="varchar(1000)"> A <i>file
                path</i> is the actual name and location of a file on a machine. </rs:domain>
            <rs:domain id="url-domain" title="URL for file" sql-type="varchar(1000)"> A <i>URL</i>
                is a relative path to a file for the database web site or the absolute path to a
                networked resource.</rs:domain>
            <rs:domain id="long-string-domain" title="Long string values" sql-type="varchar(max)"> 
                A <i>Long String Value</i> is the maximum varchar string, e.g., for concatenating
                string values </rs:domain>
            <rs:domain id="string-domain" title="String values" sql-type="varchar(1000)"> 
                A <i>String Value</i> is the value for a keyword or other entity </rs:domain>
            </rf:section>
        <rf:section id="numeric-domains" title="Numeric domains">
            <rs:domain id="count-domain" title="Count" sql-type="int"> A <i>count</i> is up to 2^31 </rs:domain>
            <rs:domain id="count-32000-domain" title="Count up to 32,000" sql-type="smallint"> A
                <i>count-32000</i> is -32,768 to 32,767 (16 bits)</rs:domain>
            <rs:domain id="count-255-domain" title="Count up to 255" sql-type="tinyint"> A
                <i>count-255</i> is 0 to 255 (8 bits) </rs:domain>
            <rs:domain id="boolean-domain" title="True or false" sql-type="bit"> A <i>boolean</i> is
                true (1) or false (0) </rs:domain>
            <rs:domain id="real-domain" title="Floating point value" sql-type="real"> A <i>real</i>
                is a 4 byte floating point number up to 10^-38</rs:domain>
            <rs:domain id="shortreal-domain" title="Short real" sql-type="float(24)">
            </rs:domain>
            
        </rf:section>
        <rf:section id="temporal-domains" title="Temporal domains">
            
        <rs:domain id="minute-time-domain" title="Short Time" sql-type="smalldatetime"> Local time of
            event in minutes. </rs:domain>
            <rs:domain id="millisec-time-domain" title="Time" sql-type="datetime"> Local time of
                event with millisecond resolution. </rs:domain>
            
        </rf:section>
    </rs:domains>

    <rs:tables>
        
        <rf:section id="road-db" title="Primary tables">
            
            <rs:table id="builds" short-name="b" title="A run of a test file" level="a">
                <rs:column id="codeline" domain="codeline-domain" index="primary_index"
                    unique="yes" index-columns="codeline,build" clustered="yes">
                    Currently non-clustered.  Will need to rebuild the database due to foreign keys.
                </rs:column>
                <rs:column id="build" domain="build-domain" >
                    Build reports assume that 'build' is ordered alphabetically within a
                    codeline.
                </rs:column>
                <rs:column id="build_date" domain="minute-time-domain">
                    If a build is only known from new_testcase_pass, its build-date is '2100-01-01'.
                </rs:column>
            </rs:table>

        </rf:section>
        <rf:section id="permanent-tables" title="Permanent tables">
            These tables do not exist else where.  Do not delete.
            <rs:table id="configuration" short-name="c" title="Configuration keywords and their 
                values" level="y">
                <rs:column id="section" domain="name-id-domain" unique="yes"
                    index-columns="section,keyword">
                    <i>Section</i> identifies a group of keywords.
                </rs:column>
                <rs:column id="keyword" domain="name-id-domain" />
                <rs:column id="value" domain="string-domain" />
            </rs:table>
            
            <rs:table id="eventlog" short-name="ev" title="Event and message log" level="y">
                <rs:column id="logtime" domain="millisec-time-domain" default="getdate()"
                    index-columns="logtime,event_type"/>
                <rs:column id="event_type" domain="event-type-domain"/>
                <rs:column id="event" domain="event-domain"/>
                <rs:column id="value" domain="count-domain" null="yes">
                    Optional integer value
                </rs:column>
                <rs:column id="message" domain="long-string-domain" null="yes"/>
            </rs:table>
            
         </rf:section><rf:section id="import-data" title="Imported tables">
            Imported data should not depend on other tables.  Use 'level="a"'."  Use 'isnew' to
            record processed entries.  All of these tables are temporary and may be deleted as
             needed.           
        </rf:section>

        <rf:section id="derived-tables" title="Derived tables">
            Maintained by rdz_DatabaseNewTables.
              <rs:table id="data_errors" short-name="de" title="Imported data errors" level="y">
                  Cleared at the beginning of each import.
                  <rs:column id="ID" domain="string-domain"/>
                  <rs:column id="build" domain="build-domain" foreign-key="no">
                      To rebuild, use rdz_DeleteBuildsFrom this_build.
                  </rs:column>
                  <rs:column id="field_name" domain="name-id-domain"/>
                  <rs:column id="table_name" domain="name-id-domain"/>
                  <rs:column id="reason" domain="string-domain"/>
                  <rs:column id="row_num" domain="count-domain" default="0"/>
              </rs:table>
            
            <rs:table id="domain_values" short-name="dv" title="Value counts for each
                name-id column" level="y">
                <rs:column id="tbl" domain="string-domain"/>
                <rs:column id="col" domain="string-domain"/>
                <rs:column id="val" domain="string-domain"/>
                <rs:column id="cnt" domain="count-domain" default="0"/>
            </rs:table>
          
        </rf:section>
    </rs:tables>
    <rs:views>
        <rf:section id="table-functions" title="Parameterized Views">
            
           <rs:table id="rf_build_testcases" short-name="rbt" title="Classify test cases">
               Classify test cases from @first_build to @last_build as compared to @prev_codeline/@prev_build
               <p>Arguments: prev_codeline, prev_build, codeline, first_build, last_build </p>
                 <rs:column id="build" view-table="builds">
                    The max run for each build in the table.  Does not include the comparison build
                </rs:column>
               </rs:table><p>Parameterized views (aka <i>inline table functions</i>) are used for summary reports
                and comparisons between builds.  To view all fields of the data tables, see <rf:iref
                    item="views"/>.  
            </p>
        </rf:section>
        
        <rf:section id="views" title="Views">
            See 
            <a href="../RoadDB/sql/Road-views.sql">Road-views.sql</a>.  
            
            <rs:table id="rdv_testcases" short-name="t" 
                title="All fields for test cases of the max run for each build">
                 <rs:column id="build" view-table="rf_build_testcases"/>
            </rs:table>
            
        </rf:section>
    </rs:views>
    <rs:data>
        <rf:section id="Predefined data">
            <rs:table-data table="configuration" index-index-columns="section, keyword, value">
                <rs:row-data values="'testsuite-type', 'wsrun', 'Tested with wsrun'"/>
             </rs:table-data>
            
        </rf:section>
    </rs:data>
</database-schema>
