Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Bd venta.sql

140 views

Published on

  • Be the first to comment

  • Be the first to like this

Bd venta.sql

  1. 1. USE [pventa] GO /****** Object: Table [dbo].[users] Script Date: 09/08/2011 17:27:43 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[users]( [user_login] [nvarchar](50) NOT NULL, [user_password] [nvarchar](250) NULL, [nombre] [nvarchar](150) NULL, [activo] [bit] NOT NULL, [ventas] [bit] NOT NULL, [reportes] [bit] NOT NULL, [administrar] [bit] NOT NULL, [fecha_registro] [datetime] NOT NULL, CONSTRAINT [PK_users] PRIMARY KEY CLUSTERED ( [user_login] 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 /****** Object: Table [dbo].[unidad_medida] Script Date: 09/08/2011 17:27:43 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[unidad_medida]( [id_unidad_medida] [smallint] NOT NULL, [unidad_medida] [nvarchar](150) NULL, CONSTRAINT [PK_unidad_medida] PRIMARY KEY CLUSTERED ( [id_unidad_medida] 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 /****** Object: Table [dbo].[productos] Script Date: 09/08/2011 17:27:43 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[productos]( [id_producto] [nvarchar](50) NOT NULL, [producto] [nvarchar](250) NULL, [id_unidad_medida] [smallint] NULL, [p_compra] [float] NULL, [p_venta] [float] NULL, [existencia] [float] NULL, CONSTRAINT [PK_productos] PRIMARY KEY CLUSTERED ( [id_producto] 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 /****** Object: Table [dbo].[venta] Script Date: 09/08/2011 17:27:43 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO
  2. 2. CREATE TABLE [dbo].[venta]( [id_venta] [int] IDENTITY(1,1) NOT NULL, [fecha_registro] [datetime] NOT NULL, [user_login] [nvarchar](50) NOT NULL, CONSTRAINT [PK_venta] PRIMARY KEY CLUSTERED ( [id_venta] 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 /****** Object: Table [dbo].[venta_detalle_tmp] Script Date: 09/08/2011 17:27:43 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[venta_detalle_tmp]( [id_venta_detalle_tmp] [int] IDENTITY(1,1) NOT NULL, [id_producto] [nvarchar](50) NOT NULL, [cantidad] [float] NOT NULL, [user_login] [nvarchar](50) NOT NULL, [p_venta] [float] NOT NULL, CONSTRAINT [PK_venta_detalle_tmp] PRIMARY KEY CLUSTERED ( [id_venta_detalle_tmp] 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 /****** Object: Table [dbo].[venta_detalle] Script Date: 09/08/2011 17:27:43 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[venta_detalle]( [id_venta_detalle] [int] IDENTITY(1,1) NOT NULL, [id_venta] [int] NOT NULL, [id_producto] [nvarchar](50) NOT NULL, [cantidad] [float] NOT NULL, [p_venta] [float] NOT NULL, CONSTRAINT [PK_venta_detalle] PRIMARY KEY CLUSTERED ( [id_venta_detalle] 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 /****** Object: Default [DF_users_fecha_registro] Script Date: 09/08/2011 17:27:43 ******/ ALTER TABLE [dbo].[users] ADD CONSTRAINT [DF_users_fecha_registro] DEFAULT (getdate()) FOR [fecha_registro] GO /****** Object: Default [DF_venta_fecha_registro] Script Date: 09/08/2011 17:27:43 ******/ ALTER TABLE [dbo].[venta] ADD CONSTRAINT [DF_venta_fecha_registro] DEFAULT (getdate()) FOR [fecha_registro] GO /****** Object: ForeignKey [FK_productos_unidad_medida] Script Date: 09/08/2011 17:27:43 ******/ ALTER TABLE [dbo].[productos] WITH CHECK ADD CONSTRAINT [FK_productos_unidad_medida] FOREIGN KEY([id_unidad_medida]) REFERENCES [dbo].[unidad_medida] ([id_unidad_medida])
  3. 3. GO ALTER TABLE [dbo].[productos] CHECK CONSTRAINT [FK_productos_unidad_medida] GO /****** Object: ForeignKey [FK_venta_users] Script Date: 09/08/2011 17:27:43 ******/ ALTER TABLE [dbo].[venta] WITH CHECK ADD CONSTRAINT [FK_venta_users] FOREIGN KEY([user_login]) REFERENCES [dbo].[users] ([user_login]) GO ALTER TABLE [dbo].[venta] CHECK CONSTRAINT [FK_venta_users] GO /****** Object: ForeignKey [FK_venta_detalle_productos] Script Date: 09/08/2011 17:27:43 ******/ ALTER TABLE [dbo].[venta_detalle] WITH CHECK ADD CONSTRAINT [FK_venta_detalle_productos] FOREIGN KEY([id_producto]) REFERENCES [dbo].[productos] ([id_producto]) GO ALTER TABLE [dbo].[venta_detalle] CHECK CONSTRAINT [FK_venta_detalle_productos] GO /****** Object: ForeignKey [FK_venta_detalle_venta] Script Date: 09/08/2011 17:27:43 ******/ ALTER TABLE [dbo].[venta_detalle] WITH CHECK ADD CONSTRAINT [FK_venta_detalle_venta] FOREIGN KEY([id_venta]) REFERENCES [dbo].[venta] ([id_venta]) GO ALTER TABLE [dbo].[venta_detalle] CHECK CONSTRAINT [FK_venta_detalle_venta] GO /****** Object: ForeignKey [FK_venta_detalle_tmp_productos] Script Date: 09/08/2011 17:27:43 ******/ ALTER TABLE [dbo].[venta_detalle_tmp] WITH CHECK ADD CONSTRAINT [FK_venta_detalle_tmp_productos] FOREIGN KEY([id_producto]) REFERENCES [dbo].[productos] ([id_producto]) GO ALTER TABLE [dbo].[venta_detalle_tmp] CHECK CONSTRAINT [FK_venta_detalle_tmp_productos] GO /****** Object: ForeignKey [FK_venta_detalle_tmp_users] Script Date: 09/08/2011 17:27:43 ******/ ALTER TABLE [dbo].[venta_detalle_tmp] WITH CHECK ADD CONSTRAINT [FK_venta_detalle_tmp_users] FOREIGN KEY([user_login]) REFERENCES [dbo].[users] ([user_login]) GO ALTER TABLE [dbo].[venta_detalle_tmp] CHECK CONSTRAINT [FK_venta_detalle_tmp_users] GO

×