create table empleado( IdEmpleado int not null

Anuncio
create database bd_pedido;
use bd_pedido;
create table empleado(
IdEmpleado int not null,
Nombre char(50) not null,
Direccion varchar(100) not null,
constraint pk_empleado primary key(IdEmpleado)
);
create table cliente(
IdCliente int not null,
Nombre char(50) not null,
Direccion varchar(100) not null,
constraint pk_cliente primary key(IdCliente)
);
create table producto(
IdProducto int not null,
Descripcion char(30) not null,
Existencia int not null,
Precio float not null,
constraint pk_producto primary key(IdProducto)
);
create table pedido(
IdOrden int not null,
Fecha datetime not null,
IdEmpleado int not null,
IdCliente int not null,
constraint pk_pedido primary key(IdOrden),
constraint fk1_pedido foreign key(IdEmpleado) references
empleado(IdEmpleado) on delete cascade on update cascade,
constraint fk2_pedido foreign key(IdCliente) references
cliente(IdCliente) on delete cascade on update cascade
);
create table detalle(
IdOrden int not null,
IdProducto int not null,
Cantidad int not null,
constraint pk_detalle primary key(IdOrden, IdProducto),
constraint fk1_detalle foreign key(IdOrden) references
pedido(IdOrden) on delete cascade on update cascade,
constraint fk2_detalle foreign key(IdProducto) references
producto(IdProducto) on delete cascade on update cascade
);
alter authorization on database :: bd_pedido to sa;
Descargar