<?xml version="1.0" encoding="UTF-8"?>
<model xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.cems.uwe.ac.uk/xmlwiki/ER/model.xsd" name="Degree Confluence">
    <type name="status">
        <enum value="successful"/>
        <enum value="incomplete"/>
    </type>
    <type name="kind">
        <enum value="primary"/>
        <enum value="secondary"/>
        <enum value="water"/>
        
    </type>
    <type name="progress">
        <enum value="active"/>
        <enum value="pending"/>
        <enum value="submitting"/>
    </type>
    <type name="html">
        <comment>To hold a minimal subset of xhtml, including p and a </comment>
        
    </type>
    <type name="image" datatype="MEDIUMBLOB">
        <comment>To hold a JPEG bit image</comment>
    </type>
    <entity name="Country">
        <attribute name="countryName"/>
    </entity>
    <entity name="Location">
        
        <attribute name="locationName" primarykey="true"/>
        <attribute name="latitude" datatype="decimal( 10,5)"/>
        <attribute name="longitude" datatype="decimal( 10,5)"/>
    </entity>
    <entity name="Region">
        <attribute name="regionName"/>
    </entity>
    <entity name="Confluence">
        <attribute name="latitude" datatype="int" primarykey="true">
            
            <comment>signed whole degrees</comment>
        </attribute>
        <attribute name="longitude" datatype="int" primarykey="true">
            <comment>signed whole degrees</comment>
        </attribute>
        <attribute name="altitude" datatype="int">
            <comment>in metres</comment>
            
        </attribute>
        <attribute name="kind" type="kind"/>
    </entity>
    <entity name="Visit">
        <attribute name="visitid" autoincrement="true" primarykey="true"/>
        <attribute name="dateVisited" datatype="DATE"/>
        <attribute name="description" type="html">
            <comment>The descriptiion is multilingual - e,g Brazilian and English so this is really
                multi-valued, differentiated by the language code</comment>
            
        </attribute>
        <attribute name="accuracy">
            <comment>Accuracy in m of visit </comment>
        </attribute>
        <attribute name="status" type="status"/>
        <attribute name="progress" type="progress"/>
    </entity>
    <entity name="Picture">
        
        <attribute name="seqno" datatype="int" primarykey="true"/>
        <attribute name="image" type="image"/>
        <attribute name="title">
            <comment>Used to describe direction and subject of photo</comment>
        </attribute>
    </entity>
    <entity name="Visitor">
        <attribute name="visitorid" datatype="int" primarykey="true"/>
        
        <attribute name="name"/>
        <attribute name="email"/>
        <attribute name="totalVisits" datatype="int" derived="true">
            <comment>number of all visits</comment>
        </attribute>
        <attribute name="uniqueVisits" datatype="int" derived="true">
            <comment>number of all confluences visited</comment>
        </attribute>
        
    </entity>
    <relationship>
        <role entity="Region"/>
        <role entity="Location" min="0" max="N" dependent="true"/>
    </relationship>
    <relationship name="directions" derived="true">
        <role entity="Location" max="N"/>
        <role entity="Confluence"/>
        <attribute name="distance">
            
            <comment>in kilometers </comment>
        </attribute>
        <attribute name="compassPoint">
            <comment>16 point compass eg. SSW</comment>
        </attribute>
        <comment>Describes the location of a Confluence relative to the nearest town</comment>
    </relationship>
    
    <relationship>
        <role entity="Confluence"/>
        <role entity="Visit" min="0" max="N"/>
    </relationship>
    <relationship>
        <role entity="Visit"/>
        <role entity="Picture" dependent="true" min="0" max="N"/>
    </relationship>
    <relationship>
        
        <role entity="Visit"/>
        <role entity="Visitor" min="0" max="N"/>
    </relationship>
    <relationship>
        <role entity="Country"/>
        <role entity="Region" dependent="true" min="0" max="N"/>
    </relationship>
    <relationship>
        <role entity="Region"/>
        
        <role entity="Confluence" min="0" max="N"/>
    </relationship>
    <comment>
        <p>This is a conceptual model of the <a href="http://confluence.org/">degree confluence
            site</a>. </p>
        <p>The model omits a number of derived counts - for example of the number of visited
            Confluences in a Country</p>
    </comment>
</model>
