view Agendas/trunk/db/v1.0/00 - Tablas.sql @ 277:7439d7a5f8d0

Warning HTML: Cambiado ALT por TITLE.
author juanjose.montesdeocaarbos
date Tue, 20 Dec 2011 08:28:33 -0300
parents 5346c0500594
children 6f5ab71614d4
line wrap: on
line source

DROP TABLE TrackLog
DROP TABLE Track
DROP TABLE Evento
DROP TABLE Cuenta
DROP TABLE Roles
DROP TABLE Persona
GO


CREATE TABLE Persona(
	Id uniqueidentifier NOT NULL,
	Nombre nvarchar(255) NULL,
	Mail nvarchar(255) NULL,
	Twitter nvarchar(255) NULL,
	Blog nvarchar(255) NULL,
	CONSTRAINT PK_Persona PRIMARY KEY (Id),
	CONSTRAINT UK_Persona_Nombre UNIQUE (Nombre),
	CONSTRAINT UK_Persona_Twitter UNIQUE (Twitter))	
GO

CREATE TABLE Roles(
	Persona uniqueidentifier NOT NULL,
	Rol nvarchar(25) NOT NULL,
	CONSTRAINT PK_Roles PRIMARY KEY (Persona, Rol),
	CONSTRAINT FK_Roles_Persona FOREIGN KEY(Persona) REFERENCES Persona (Id) ON DELETE CASCADE
)
GO

CREATE TABLE Evento(
	Id uniqueidentifier NOT NULL,
	Titulo nvarchar(255) NULL,
	FechaInicio datetime NULL,
	FechaTermino datetime NULL,
	UrlInvitacion nvarchar(255) NULL,
	UrlWiki nvarchar(255) NULL,
	NumeroOrden smallint NULL,
	Ponente uniqueidentifier NULL,
	Estado nvarchar(25) NULL,
	Tipo int NULL,
	Duracion bigint NULL,
	CONSTRAINT PK_Evento PRIMARY KEY (Id),
	CONSTRAINT UK_Titulo UNIQUE (Titulo),
	CONSTRAINT FK_Evento_Persona FOREIGN KEY(Ponente) REFERENCES Persona (Id)
)
GO

CREATE TABLE Cuenta(
	Id uniqueidentifier NOT NULL,
	Persona uniqueidentifier NULL,
	LogonName nvarchar(255) NULL,
	IdentityProvider int NULL,
	CONSTRAINT PK_Cuenta PRIMARY KEY (Id),
	CONSTRAINT FK_Cuenta_Persona FOREIGN KEY(Persona) REFERENCES Persona (Id) ON DELETE CASCADE
)
GO

CREATE TABLE Track(
	Id uniqueidentifier NOT NULL,
	Evento uniqueidentifier NULL,
	Accion int NULL,
	Usuario uniqueidentifier NULL,
	CONSTRAINT PK_Track PRIMARY KEY (Id),
	CONSTRAINT FK_Track_Usuario FOREIGN KEY(Usuario)REFERENCES Persona (Id),
	CONSTRAINT FK_Track_Evento FOREIGN KEY(Evento) REFERENCES Evento (Id) ON DELETE CASCADE
)
GO

CREATE TABLE TrackLog(
	Id uniqueidentifier NOT NULL,
	Propietario int NULL,
	Mensaje nvarchar(255) NULL,
	Track uniqueidentifier NULL,
	Usuario uniqueidentifier NULL,
	Successful bit NULL,
	Fecha datetime NULL,
	CONSTRAINT PK_TrackLog PRIMARY KEY (Id),
	CONSTRAINT FK_TrackLog_Usuario FOREIGN KEY(Usuario)REFERENCES Persona (Id),
	CONSTRAINT FK_TrackLog_Track FOREIGN KEY(Track)REFERENCES Track (Id) ON DELETE CASCADE
)
GO