<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">

	<xsd:annotation>
		<xsd:documentation xml:lang="en">
			tables schema for DataMgr components
		</xsd:documentation>
	</xsd:annotation>

	<xsd:element name="tables">
		<xsd:complexType>
			<xsd:sequence>
				<xsd:element name="table" type="tableType" minOccurs="1" maxOccurs="unbounded" />
				<xsd:element name="data" type="seedType" minOccurs="0" maxOccurs="unbounded">
					<xsd:annotation>
						<xsd:documentation>Adds data to table on table creation only.</xsd:documentation>
					</xsd:annotation>
				</xsd:element>
			</xsd:sequence>
		</xsd:complexType>
	</xsd:element>

	<xsd:complexType name="tableType">
		<xsd:sequence>
			<xsd:element name="field" type="fieldType" minOccurs="1" maxOccurs="unbounded" />
			<xsd:element name="data" type="seedTypeNested" minOccurs="0" maxOccurs="1">
				<xsd:annotation>
					<xsd:documentation>Adds data to table on table creation only.</xsd:documentation>
				</xsd:annotation>
			</xsd:element>
		</xsd:sequence>
		<xsd:attribute name="name" type="xsd:string" use="required" />
	</xsd:complexType>

	<xsd:complexType name="fieldType">
		<xsd:sequence>
			<xsd:element name="relation" type="relationType" minOccurs="0" />
		</xsd:sequence>
		<xsd:attribute name="ColumnName" type="xsd:string" use="required" />
		<xsd:attribute name="CF_DataType" type="cfDataType" use="required" />
		<xsd:attribute name="PrimaryKey" type="xsd:boolean" default="false" />
		<xsd:attribute name="Increment" type="xsd:boolean" default="false" />
		<xsd:attribute name="Length" type="xsd:positiveInteger" />
		<xsd:attribute name="Default" type="xsd:string" />
		<xsd:attribute name="AllowNulls" type="xsd:boolean" default="true" />
		<xsd:attribute name="Precision" type="xsd:positiveInteger" default="12" />
		<xsd:attribute name="Scale" type="xsd:positiveInteger" default="2" />
		<xsd:attribute name="Special">
			<xsd:simpleType>
				<xsd:restriction base="xsd:string">
					<xsd:enumeration value="CreationDate" />
					<xsd:enumeration value="LastUpdatedDate" />
					<xsd:enumeration value="DeletionMark" />
					<xsd:enumeration value="Sorter" />
				</xsd:restriction>
			</xsd:simpleType>
		</xsd:attribute>
	</xsd:complexType>
	
	<xsd:complexType name="relationType">
		<xsd:sequence>
			<xsd:element name="filter" type="filterType" minOccurs="0" maxOccurs="unbounded" />
		</xsd:sequence>
		<xsd:attribute name="type" use="required">
			<xsd:simpleType>
				<xsd:restriction base="xsd:string">
					<xsd:enumeration value="avg" />
					<xsd:enumeration value="count" />
					<xsd:enumeration value="max" />
					<xsd:enumeration value="min" />
					<xsd:enumeration value="sum" />
					<xsd:enumeration value="label" />
					<xsd:enumeration value="concat" />
					<xsd:enumeration value="list" />
					<xsd:enumeration value="has" />
					<xsd:enumeration value="hasnot" />
					<xsd:enumeration value="math" />
					<xsd:enumeration value="now" />
					<xsd:enumeration value="custom" />
				</xsd:restriction>
			</xsd:simpleType>
		</xsd:attribute>
		<xsd:attribute name="field" type="xsd:string" use="required" />
		<xsd:attribute name="table" type="xsd:string" />
		<xsd:attribute name="join-field-local" type="xsd:string" />
		<xsd:attribute name="join-field-remote" type="xsd:string" />
		<xsd:attribute name="join-field" type="xsd:string" />
		<xsd:attribute name="delimiter" type="xsd:string" />
		<xsd:attribute name="sort-field" type="xsd:string" />
		<xsd:attribute name="bidirectional" type="xsd:string" />
		<xsd:attribute name="join-table" type="xsd:string" />
		<xsd:attribute name="join-table-field-local" type="xsd:string" />
		<xsd:attribute name="join-table-field-remote" type="xsd:string" />
		<xsd:attribute name="local-table-join-field" type="xsd:string" />
		<xsd:attribute name="remote-table-join-field" type="xsd:string" />
		<xsd:attribute name="sql" type="xsd:string" />
		<xsd:attribute name="CF_DataType" type="cfDataType" />
		<xsd:attribute name="field1" type="xsd:string" />
		<xsd:attribute name="field2" type="xsd:string" />
		<xsd:attribute name="operator">
			<xsd:simpleType>
				<xsd:restriction base="xsd:string">
					<xsd:enumeration value="+" />
					<xsd:enumeration value="-" />
					<xsd:enumeration value="*" />
					<xsd:enumeration value="/" />
				</xsd:restriction>
			</xsd:simpleType>
		</xsd:attribute>
		<xsd:attribute name="onDelete">
			<xsd:simpleType>
				<xsd:restriction base="xsd:string">
					<xsd:enumeration value="Cascade" />
					<xsd:enumeration value="Error" />
					<xsd:enumeration value="Ignore" />
				</xsd:restriction>
			</xsd:simpleType>
		</xsd:attribute>
	</xsd:complexType>

	<xsd:complexType name="filterType">
		<xsd:attribute name="field" type="xsd:string" use="required" />
		<xsd:attribute name="value" type="xsd:string" use="required" />
		<xsd:attribute name="operator" default="=">
			<xsd:simpleType>
				<xsd:restriction base="xsd:string">
					<xsd:enumeration value="=" />
					<xsd:enumeration value="&gt;" />
					<xsd:enumeration value="&lt;" />
					<xsd:enumeration value="&gt;=" />
					<xsd:enumeration value="&lt;=" />
					<xsd:enumeration value="LIKE" />
					<xsd:enumeration value="NOT LIKE" />
					<xsd:enumeration value="&gt;&lt;" />
					<xsd:enumeration value="IN" />
				</xsd:restriction>
			</xsd:simpleType>
		</xsd:attribute>
	</xsd:complexType>
	
	<xsd:simpleType name="cfDataType">
		<xsd:restriction base="xsd:string">
			<xsd:enumeration value="CF_SQL_BIGINT" />
			<xsd:enumeration value="CF_SQL_BIT" />
			<xsd:enumeration value="CF_SQL_CHAR" />
			<xsd:enumeration value="CF_SQL_DATE" />
			<xsd:enumeration value="CF_SQL_DECIMAL" />
			<xsd:enumeration value="CF_SQL_DOUBLE" />
			<xsd:enumeration value="CF_SQL_FLOAT" />
			<xsd:enumeration value="CF_SQL_IDSTAMP" />
			<xsd:enumeration value="CF_SQL_INTEGER" />
			<xsd:enumeration value="CF_SQL_LONGVARCHAR" />
			<xsd:enumeration value="CF_SQL_MONEY" />
			<xsd:enumeration value="CF_SQL_MONEY4" />
			<xsd:enumeration value="CF_SQL_NUMERIC" />
			<xsd:enumeration value="CF_SQL_REAL" />
			<xsd:enumeration value="CF_SQL_REFCURSOR" />
			<xsd:enumeration value="CF_SQL_SMALLINT" />
			<xsd:enumeration value="CF_SQL_TIME" />
			<xsd:enumeration value="CF_SQL_TIMESTAMP" />
			<xsd:enumeration value="CF_SQL_TINYINT" />
			<xsd:enumeration value="CF_SQL_VARCHAR" />
		</xsd:restriction>
	</xsd:simpleType>
	
	<xsd:simpleType name="onexistsType">
		<xsd:restriction base="xsd:string">
			<xsd:enumeration value="ignore" />
			<xsd:enumeration value="update" />
		</xsd:restriction>
	</xsd:simpleType>

	<xsd:complexType name="seedType">
		<xsd:sequence>
			<xsd:element name="row" minOccurs="1" type="rowType" />
		</xsd:sequence>
		<xsd:attribute name="table" type="xsd:string" use="required" />
	</xsd:complexType>
	
	<xsd:complexType name="seedTypeNested">
		<xsd:sequence>
			<xsd:element name="row" minOccurs="1" type="rowType" />
		</xsd:sequence>
	</xsd:complexType>

	<xsd:complexType name="rowType">
		<xsd:sequence>
			<xsd:element name="field" minOccurs="0">
				<xsd:complexType>
					<xsd:sequence>
						<xsd:element name="relfield" minOccurs="0">
							<xsd:complexType>
								<xsd:attribute name="name" type="xsd:string" />
								<xsd:attribute name="value" type="xsd:string" />
							</xsd:complexType>
						</xsd:element>
					</xsd:sequence>
					<xsd:attribute name="name" type="xsd:string" />
					<xsd:attribute name="value" type="xsd:string" />
					<xsd:attribute name="reltable" type="xsd:string" />
					<xsd:attribute name="relfield" type="xsd:string" />
					<xsd:anyAttribute />
				</xsd:complexType>
			</xsd:element>
		</xsd:sequence>
		<xsd:anyAttribute />
	</xsd:complexType>
	
</xsd:schema>