﻿CREATE TABLE [session].[Session]
(
	Id			BIGINT NOT NULL PRIMARY KEY IDENTITY,
	[Name]		[session].[SessionName] NOT NULL UNIQUE,
	Created		DATETIMEOFFSET NOT NULL DEFAULT SYSDATETIMEOFFSET(),
	GameOver	BIT NOT NULL DEFAULT 0,
	Player1Id	BIGINT NOT NULL,
	Player2Id	BIGINT NULL,

	CONSTRAINT FK_Player1_User FOREIGN KEY (Player1Id) REFERENCES [user].[User] (Id) 
		ON DELETE CASCADE 
		ON UPDATE CASCADE,
	CONSTRAINT FK_Player2_User FOREIGN KEY (Player2Id) REFERENCES [user].[User] (Id) 
		ON DELETE NO ACTION
		ON UPDATE NO ACTION
)
