<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="schemaMeta">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="comments"/>
                <xs:element ref="tables"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:element name="comments" type="xs:string"/>
    <xs:element name="tables">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="table" minOccurs="0" maxOccurs="unbounded"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:element name="table">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="column" minOccurs="0" maxOccurs="unbounded"/>
            </xs:sequence>
            <xs:attribute name="name" type="xs:string" use="required"/>
            <xs:attribute name="comments" type="xs:string"/>
            <xs:attribute name="remoteSchema" type="xs:string">
                <xs:annotation>
                    <xs:documentation>
                        Specifies that this table exists in another schema.
                    </xs:documentation>
                </xs:annotation>
            </xs:attribute>
        </xs:complexType>
    </xs:element>
    <xs:element name="column">
        <xs:complexType>
            <xs:sequence minOccurs="0">
                <xs:element ref="foreignKey"/>
            </xs:sequence>
            <xs:attribute name="name" type="xs:string" use="required"/>
            <xs:attribute name="comments" type="xs:string"/>
            <xs:attribute name="primaryKey" type="xs:boolean">
                <xs:annotation>
                    <xs:documentation>
                        Specifies that this column is a primary key of
                        its table. Defaults to false.
                    </xs:documentation>
                </xs:annotation>
            </xs:attribute>
            <xs:attribute name="disableImpliedKeys">
                <xs:annotation>
                    <xs:documentation>
                        Explicitly disables relationships to or from
                        this column that may be implied by the column's
                        name, type and size.
                        
                        Defaults to none.
                    </xs:documentation>
                </xs:annotation>
                <xs:simpleType>
                    <xs:restriction base="xs:string">
                        <xs:enumeration value="from"/>
                        <xs:enumeration value="to"/>
                        <xs:enumeration value="all"/>
                        <xs:enumeration value="none"/>
                    </xs:restriction>
                </xs:simpleType>
            </xs:attribute>
            <xs:attribute name="disableDiagramAssociations">
                <xs:annotation>
                    <xs:documentation>
                        Sometimes the associations displayed on a relationships
                        diagram cause the diagram to become much more cluttered
                        than it needs to be.  Enable this setting to not show 
                        the relationships between this column and other columns.
                        
                        Use exceptDirect to disable associations on all diagrams except
                        for the diagrams of tables directly (within one degree of separation)
                        connected to this column.
                         
                        Defaults to none.
                    </xs:documentation>
                </xs:annotation>
                <xs:simpleType>
                    <xs:restriction base="xs:string">
                        <xs:enumeration value="all"/>
                        <xs:enumeration value="exceptDirect"/>
                        <xs:enumeration value="none"/>
                    </xs:restriction>
                </xs:simpleType>
            </xs:attribute>
        </xs:complexType>
    </xs:element>
    <xs:element name="foreignKey">
        <xs:annotation>
            <xs:documentation>
                Associates this column with the primary key of another
                table.
            </xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:attribute name="remoteSchema" type="xs:string">
                <xs:annotation>
                    <xs:documentation>
                        Specifies that the referenced table exists in
                        another schema.
                    </xs:documentation>
                </xs:annotation></xs:attribute>
            <xs:attribute name="table" type="xs:string" use="required"/>
            <xs:attribute name="column" type="xs:string" use="required"/>
        </xs:complexType>
    </xs:element>
</xs:schema>
