Essays.club - Ensayos gratis, notas de cursos, notas de libros, tareas, monografías y trabajos de investigación
Buscar

Validación y programación MySQL

Enviado por   •  18 de Septiembre de 2017  •  970 Palabras (4 Páginas)  •  458 Visitas

Página 1 de 4

...

TABLA País

IDPais

NomPais

1

México

TABLA Estado

IDEstado

NomEstado

IDPais

15

Nuevo León

1

TABLA Ciudad

IDCiudad

NomCiudad

IDEstado

12

Monterrey

15

create table factura (

NumFactura INT (20) NOT NULL PRIMARY KEY,

Fecha date NOT NULL,

PrecioTotal INT (20) NOT NULL,

NumCli INT (20) NOT NULL,

IDDetalle INT (20) NOT NULL);

create table pais (

IDPais INT (20) NOT NULL PRIMARY KEY,

NomPais VARCHAR (30) NOT NULL);

create table estado (

IDEstado INT (20) NOT NULL PRIMARY KEY,

NomEstado VARCHAR (30) NOT NULL,

IDPais INT (20) NOT NULL,

constraint fk_IDPais_estado foreign key (IDPais) references pais (IDPais));

create table ciudad (

IDCiudad INT (20) NOT NULL PRIMARY KEY,

NomCiudad VARCHAR (30) NOT NULL,

IDEstado INT (20) NOT NULL,

constraint fk_IDEstado_ciudad foreign key (IDEstado) references estado (IDEstado));

create table cliente (

NumCli INT (20) NOT NULL PRIMARY KEY,

CP INT (20) NOT NULL,

Calle VARCHAR (30) NOT NULL,

NumDepto INT (20) NOT NULL,

Nombre VARCHAR (30) NOT NULL,

IDPais INT (20) NOT NULL,

IDEstado INT (20) NOT NULL,

IDCiudad INT (20) NOT NULL,

Email VARCHAR (30) NOT NULL,

NumTel INT (20) NOT NULL,

constraint fk_IDPais_cliente foreign key (IDPais) references pais (IDPais),

constraint fk_IDEstado_cliente foreign key (IDEstado) references estado (IDEstado),

constraint fk_IDCiudad_cliente foreign key (IDCiudad) references ciudad (IDCiudad));

create table inspector (

IDInspector INT (20) NOT NULL PRIMARY KEY,

NumInsp INT (20) NOT NULL,

EmailInsp VARCHAR (30) NOT NULL,

NumTelInsp INT (20) NOT NULL);

create table estufa (

NumDeSerie INT (20) NOT NULL PRIMARY KEY,

Tipo VARCHAR (20) NOT NULL,

FechaFabricacion date NOT NULL,

IDInspector INT (20) NOT NULL,

constraint fk_IDInspector_estufa foreign key (IDInspector) references inspector (IDInspector));

create table parte (

NumeroParte INT (20) NOT NULL PRIMARY KEY,

Descripcion VARCHAR (20) NOT NULL,

Costo INT (20) NOT NULL,

PrecioVenta INT (20) NOT NULL);

create table reparacion (

NumReparacion INT (20) NOT NULL PRIMARY KEY,

Descripcion VARCHAR (20) NOT NULL,

CantidadTotalReparacion INT (20) NOT NULL,

IDDetalle INT (20) NOT NULL);

create table detalle (

IDDEtalle INT (20) NOT NULL PRIMARY KEY,

NumReparacion INT (20) NOT NULL,

NumeroParte INT (20) NOT NULL,

Cantidad INT (20) NOT NULL,

NumDeSerie INT (20) NOT NULL,

SubTotalPartes INT (20) NOT NULL,

constraint fk_NumReparacion_detalle foreign key (NumReparacion) references reparacion (NumReparacion),

constraint fk_NumeroParte_detalle foreign key (NumeroParte) references parte (NumeroParte),

constraint fk_NumDeSerie_detalle foreign key (NumDeSerie) references estufa (NumDeSerie));

alter table reparacion add constraint fk_IDDetalle_reparacion foreign key (IDDetalle) references detalle (IDDetalle);

alter table factura add constraint fk_NumCli_factura foreign key (NumCli) references cliente (NumCli);

alter table factura add constraint fk_IDDetalle_factura foreign key (IDDetalle) references detalle (IDDetalle);

insert into pais() values('1', 'Queretaro'),('2', 'Guanajuato'),('3', 'SLP');

create table

...

Descargar como  txt (8.6 Kb)   pdf (79.3 Kb)   docx (12.8 Kb)  
Leer 3 páginas más »
Disponible sólo en Essays.club