Skip to content

Instantly share code, notes, and snippets.

@tqaw19
Created November 25, 2019 22:28
Show Gist options
  • Save tqaw19/0a30797da1f0152cfa2e61f07b18770b to your computer and use it in GitHub Desktop.
Save tqaw19/0a30797da1f0152cfa2e61f07b18770b to your computer and use it in GitHub Desktop.
create table [dbo].[Factura](
[num_factura] [int] PRIMARY KEY IDENTITY(1,1) NOT NULL,
[fecha] [Date] null,
[monto] [money] null,
[id_cliente] [int] REFERENCES [dbo].[Cliente] (id_cliente))
alter table [dbo].[Factura]
add constraint (id_producto)
add foreign key (id_producto) references [dbo].[Producto] (id_producto)
select * from producto
ALTER TABLE [dbo].[Factura] WITH CHECK ADD FOREIGN KEY([id_producto])
REFERENCES [dbo].[Producto] ([id_producto])
select * from factura
create table [dbo].[Cliente](
[id_cliente] [int] PRIMARY KEY IDENTITY(1,1) NOT NULL,
[nombre] [nvarchar] (50) null,
[apellido] [nvarchar] (50) null,
[direccion] [nvarchar] (200) null,
[fecha_nacimiento] [Date] null,
[telefono] [int] null,
[email] [nvarchar] (50) null,
[categoria] [nvarchar] (50) null)
create table [dbo].[Producto](
[id_producto] [int] PRIMARY KEY IDENTITY(1,1) NOT NULL,
[nombre] [nvarchar] (100) null,
[precio] [int] null,
[stock] [int] null,
[num_factura] [int] REFERENCES [dbo].[Factura] (num_factura))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment