<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="results" targetNamespace="http://tempuri.org/results.xsd" elementFormDefault="qualified" attributeFormDefault="qualified" xmlns="http://tempuri.org/results.xsd" xmlns:mstns="http://tempuri.org/results.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:codegen="urn:schemas-microsoft-com:xml-msprop">
	<xs:element name="results" msdata:IsDataSet="true">
		<xs:complexType>
			<xs:choice maxOccurs="unbounded">
				<xs:element name="Teams">
					<xs:complexType>
						<!-- describes what the TEAM table will look like.  each element tag is a column-->
						<xs:sequence>
							<xs:element name="TEAMID" msdata:ReadOnly="true" msdata:AutoIncrement="true" type="xs:int" />
							<xs:element name="name" type="xs:string" />
							<xs:element name="description" type="xs:string" minOccurs="0" codegen:nullValue="_empty" />
							<xs:element name="position" type="xs:int" minOccurs="0" />
							<xs:element name="points" type="xs:double" minOccurs="0" />
						</xs:sequence>
					</xs:complexType>
				</xs:element>
				<xs:element name="Scores">
					<!-- describes what the SCORES table will look like -->
					<xs:complexType>
						<xs:sequence>
							<xs:element name="ID" msdata:ReadOnly="true" msdata:AutoIncrement="true" type="xs:int" />
							<xs:element name="winner_id" type="xs:int" />
							<xs:element name="loser_id" type="xs:int" />
							<xs:element name="winnre_score" type="xs:int" minOccurs="0" />
							<xs:element name="loser_score" type="xs:int" minOccurs="0" />
							<xs:element name="updated" type="xs:string" />
						</xs:sequence>
					</xs:complexType>
				</xs:element>
			</xs:choice>
		</xs:complexType>
		<xs:unique name="resultsKey1" msdata:PrimaryKey="true">
			<xs:selector xpath=".//mstns:Teams" />
			<xs:field xpath="mstns:TEAMID" />
		</xs:unique>
		<!-- WeWonFrom describes a way to take a team from the TEAM table and look at its wins in the Scores table -->
		<xs:keyref name="WinnerTeamsScores" refer="resultsKey1" codegen:typedChildren="WeWonFrom" codegen:typedParent="Winner">
			<xs:selector xpath=".//mstns:Scores" />
			<xs:field xpath="mstns:winner_id" />
		</xs:keyref>
		<xs:key name="resultsKey3">
			<xs:selector xpath=".//mstns:Teams" />
			<xs:field xpath="mstns:TEAMID" />
		</xs:key>
		<xs:keyref name="LoserTeamsScores" refer="resultsKey3" codegen:typedChildren="WeLostTo" codegen:typedParent="Loser">
			<xs:selector xpath=".//mstns:Scores" />
			<xs:field xpath="mstns:loser_id" />
		</xs:keyref>
	</xs:element>
</xs:schema>