USE [Clinica]
GO
/****** Object:  Table [Core].[Usuario]    Script Date: 18-08-2025 21:38:25 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [Core].[Usuario](
	[IdUsuario] [int] IDENTITY(1,1) NOT NULL,
	[IdCliente] [int] NULL,
	[IdEmpresa] [int] NULL,
	[LoginName] [varchar](45) NULL,
	[Clave] [varchar](45) NULL,
	[IdContacto] [int] NOT NULL,
	[Eliminado] [int] NULL,
	[IdPerfil] [int] NULL,
	[IdTipoIdioma] [int] NOT NULL,
	[FechaCreacion] [datetime] NOT NULL,
	[FechaUltimaSesion] [datetime] NULL,
	[IdTipoClave] [int] NOT NULL,
	[Rut] [varchar](10) NULL,
 CONSTRAINT [PK_Usuario] PRIMARY KEY CLUSTERED 
(
	[IdUsuario] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [Core].[Usuario]  WITH CHECK ADD  CONSTRAINT [FK_Usuario_Cliente] FOREIGN KEY([IdCliente])
REFERENCES [Core].[Cliente] ([IdCliente])
GO
ALTER TABLE [Core].[Usuario] CHECK CONSTRAINT [FK_Usuario_Cliente]
GO
ALTER TABLE [Core].[Usuario]  WITH CHECK ADD  CONSTRAINT [FK_Usuario_Contacto] FOREIGN KEY([IdContacto])
REFERENCES [Core].[Contacto] ([IdContacto])
GO
ALTER TABLE [Core].[Usuario] CHECK CONSTRAINT [FK_Usuario_Contacto]
GO
ALTER TABLE [Core].[Usuario]  WITH CHECK ADD  CONSTRAINT [FK_Usuario_Empresa] FOREIGN KEY([IdEmpresa])
REFERENCES [Core].[Empresa] ([IdEmpresa])
GO
ALTER TABLE [Core].[Usuario] CHECK CONSTRAINT [FK_Usuario_Empresa]
GO
ALTER TABLE [Core].[Usuario]  WITH CHECK ADD  CONSTRAINT [FK_Usuario_Perfil] FOREIGN KEY([IdPerfil])
REFERENCES [Core].[Perfil] ([IdPerfil])
GO
ALTER TABLE [Core].[Usuario] CHECK CONSTRAINT [FK_Usuario_Perfil]
GO
ALTER TABLE [Core].[Usuario]  WITH CHECK ADD  CONSTRAINT [FK_Usuario_TipoClave] FOREIGN KEY([IdTipoClave])
REFERENCES [Core].[TipoClave] ([IdTipoClave])
GO
ALTER TABLE [Core].[Usuario] CHECK CONSTRAINT [FK_Usuario_TipoClave]
GO
ALTER TABLE [Core].[Usuario]  WITH CHECK ADD  CONSTRAINT [FK_Usuario_TipoIdioma] FOREIGN KEY([IdTipoIdioma])
REFERENCES [Core].[TipoIdioma] ([IdTipoIdioma])
GO
ALTER TABLE [Core].[Usuario] CHECK CONSTRAINT [FK_Usuario_TipoIdioma]
GO
