﻿CREATE TABLE [session].[Move]
(
	[Id]			INT NOT NULL PRIMARY KEY IDENTITY,
	[SessionId]		BIGINT NOT NULL,
	[From]			VARCHAR(2) NOT NULL,
	[To]			VARCHAR(2) NOT NULL,
	[IsPromotion]	BIT NOT NULL,
	[PieceIdFromHand] INT NULL

	CONSTRAINT [Cannot end where you start]
		CHECK ([From] <> [To]),

	CONSTRAINT FK_Move_Session FOREIGN KEY (SessionId) REFERENCES [session].[Session] (Id)
		ON DELETE CASCADE
		ON UPDATE CASCADE,

	CONSTRAINT FK_Move_Piece FOREIGN KEY (PieceIdFromHand) REFERENCES [session].[Piece] (Id)
		ON DELETE NO ACTION
		ON UPDATE NO ACTION
)
