CREATE TABLE [dbo].[CANASTA](
[IdCanasta] [int] IDENTITY(1,1) NOT NULL,
[Minuto] [datetime] NOT NULL,
[TipoCanasta] [varchar](36) NOT NULL,
[Puntos] [int] NOT NULL,
[IdPartido] [int] NOT NULL,
CONSTRAINT [PK_CANASTA] PRIMARY KEY CLUSTERED
(
[IdCanasta] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[EQUIPO](
[IdEquipo] [int] IDENTITY(1,1) NOT NULL,
[Codigo] [varchar](36) NOT NULL,
[Nombre] [varchar](500) NOT NULL,
[Ciudad] [varchar](250) NOT NULL,
[Aforo] [int] NOT NULL,
[Estadio] [varchar](250) NOT NULL,
[Fundacion] [datetime] NOT NULL,
CONSTRAINT [PK_EQUIPO] PRIMARY KEY CLUSTERED
(
[IdEquipo] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[JUGADOR](
[Id] [int] IDENTITY(1,1) NOT NULL,
[Codigo] [varchar](36) NOT NULL,
[Nombre] [varchar](255) NOT NULL,
[IdPosicion] [int] NOT NULL,
[FechaNacimiento] [datetime] NOT NULL,
[IdEquipo] [int] NOT NULL,
CONSTRAINT [PK_JUGADOR] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[PARTIDO](
[IdPartido] [int] IDENTITY(1,1) NOT NULL,
[Codigo] [varchar](36) NOT NULL,
[PuntosCasa] [int] NOT NULL,
[PuntosVisitantes] [int] NOT NULL,
[Fecha] [datetime] NOT NULL,
CONSTRAINT [PK_PARTIDO] PRIMARY KEY CLUSTERED
(
[IdPartido] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[PRESIDENTE](
[IdPresidente] [int] IDENTITY(1,1) NOT NULL,
[Dni] [varchar](36) NOT NULL,
[Nombre] [varchar](250) NOT NULL,
[Apellidos] [varchar](250) NOT NULL,
[FechaEleccion] [datetime] NOT NULL,
[FechaNac] [datetime] NOT NULL,
[IdEquipo] [int] NOT NULL,
CONSTRAINT [PK_PRESIDENTE] PRIMARY KEY CLUSTERED
(
[IdPresidente] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[REL_PARTIDO_EQUIPOS](
[Id] [int] IDENTITY(1,1) NOT NULL,
[IdPartido] [int] NOT NULL,
[IdEquipoLocal] [int] NOT NULL,
[IdEquipoVisitante] [int] NOT NULL,
CONSTRAINT [PK_REL_PARTIDO_EQUIPOS] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[CANASTA] WITH CHECK ADD CONSTRAINT [FK_CANASTA_PARTIDO] FOREIGN KEY([IdPartido])
REFERENCES [dbo].[PARTIDO] ([IdPartido])
GO
ALTER TABLE [dbo].[CANASTA] CHECK CONSTRAINT [FK_CANASTA_PARTIDO]
GO
ALTER TABLE [dbo].[JUGADOR] WITH CHECK ADD CONSTRAINT [FK_JUGADOR_EQUIPO] FOREIGN KEY([IdEquipo])
REFERENCES [dbo].[EQUIPO] ([IdEquipo])
GO
ALTER TABLE [dbo].[JUGADOR] CHECK CONSTRAINT [FK_JUGADOR_EQUIPO]
GO
ALTER TABLE [dbo].[PRESIDENTE] WITH CHECK ADD CONSTRAINT [FK_PRESIDENTE_EQUIPO] FOREIGN KEY([IdEquipo])
REFERENCES [dbo].[EQUIPO] ([IdEquipo])
GO
ALTER TABLE [dbo].[PRESIDENTE] CHECK CONSTRAINT [FK_PRESIDENTE_EQUIPO]
GO
ALTER TABLE [dbo].[REL_PARTIDO_EQUIPOS] WITH CHECK ADD CONSTRAINT [FK_REL_PARTIDO_EQUIPOS_EQUIPO] FOREIGN KEY([IdEquipoLocal])
REFERENCES [dbo].[EQUIPO] ([IdEquipo])
GO
ALTER TABLE [dbo].[REL_PARTIDO_EQUIPOS] CHECK CONSTRAINT [FK_REL_PARTIDO_EQUIPOS_EQUIPO]
GO
ALTER TABLE [dbo].[REL_PARTIDO_EQUIPOS] WITH CHECK ADD CONSTRAINT [FK_REL_PARTIDO_EQUIPOS_EQUIPO1] FOREIGN KEY([IdEquipoVisitante])
REFERENCES [dbo].[EQUIPO] ([IdEquipo])
GO
ALTER TABLE [dbo].[REL_PARTIDO_EQUIPOS] CHECK CONSTRAINT [FK_REL_PARTIDO_EQUIPOS_EQUIPO1]
GO
ALTER TABLE [dbo].[REL_PARTIDO_EQUIPOS] WITH CHECK ADD CONSTRAINT [FK_REL_PARTIDO_EQUIPOS_PARTIDO] FOREIGN KEY([IdPartido])
REFERENCES [dbo].[PARTIDO] ([IdPartido])
GO
ALTER TABLE [dbo].[REL_PARTIDO_EQUIPOS] CHECK CONSTRAINT [FK_REL_PARTIDO_EQUIPOS_PARTIDO]
GO