BD TALLER MECANICO
Modelo Entidad-relacion
CÓDIGO
CREATE DATABASE TALLER;
USE TALLER
CREATE TABLE IF NOT EXISTs `CLIENTE`(
`RFC` varchar(10) not null PRIMARY KEY,
`Nombre` varchar (60) not null,
`Direccion` varchar (60) not null,
`tel` varchar(10)
)ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS `MECANICO`(
`Idmec` varchar(10) not null PRIMARY KEY,
`Nombre` varchar (60) not null,
`Direccion` varchar (60) not null,
`tel` varchar(10),
`Costoxhora` DECIMAL(2) not null
)ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS `VEHICULO`(
`Matricula` varchar (10) not null PRIMARY KEY,
`Modelo` varchar (60) not null,
`Color` varchar (60),
`Fecha_ent` datetime not null,
`Hora_ent` datetime not null,
`RFC` varchar (10) not null,
`Mec` varchar(10) not null,
FOREIGN KEY (`RFC`) REFERENCES `CLIENTE` (`RFC`),
FOREIGN KEY (`Mec`) REFERENCES `MECANICO` (`Idmec`)
)ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS `REPUESTO`(
`Idrep` varchar(10) not null PRIMARY KEY,
`Descripción` varchar (60) not null,
`CostoUnit` int not null,
`PrecioUnit` int not null
)ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS `HOJAP`(
`Idhoja` varchar (10) not null PRIMARY KEY,
`concepto` varchar (100) not null,
`Cantidad` int not null,
`Reparacion` varchar(10) not null,
`Idmec` varchar(10) not null,
FOREIGN KEY (`Idmec`) REFERENCES `MECANICO` (`Idmec`),
FOREIGN KEY (`Reparacion`) REFERENCES `REPUESTO` (`Idrep`)
)ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS `FACTURA`(
`Nofact` varchar(10) not null PRIMARY KEY,
`Fecha` datetime not null,
`Imp_pesos` decimal(2) not null,
`Imp_dol` decimal(2) not null,
`RFC` varchar(10) not null,
`Idhoja` varchar(10) not null,
FOREIGN KEY (`RFC`) REFERENCES CLIENTE (`RFC`),
FOREIGN KEY (`Idhoja`) REFERENCES HOJAP (`Idhoja`)
)ENGINE = InnoDB;
USE TALLER
CREATE TABLE IF NOT EXISTs `CLIENTE`(
`RFC` varchar(10) not null PRIMARY KEY,
`Nombre` varchar (60) not null,
`Direccion` varchar (60) not null,
`tel` varchar(10)
)ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS `MECANICO`(
`Idmec` varchar(10) not null PRIMARY KEY,
`Nombre` varchar (60) not null,
`Direccion` varchar (60) not null,
`tel` varchar(10),
`Costoxhora` DECIMAL(2) not null
)ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS `VEHICULO`(
`Matricula` varchar (10) not null PRIMARY KEY,
`Modelo` varchar (60) not null,
`Color` varchar (60),
`Fecha_ent` datetime not null,
`Hora_ent` datetime not null,
`RFC` varchar (10) not null,
`Mec` varchar(10) not null,
FOREIGN KEY (`RFC`) REFERENCES `CLIENTE` (`RFC`),
FOREIGN KEY (`Mec`) REFERENCES `MECANICO` (`Idmec`)
)ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS `REPUESTO`(
`Idrep` varchar(10) not null PRIMARY KEY,
`Descripción` varchar (60) not null,
`CostoUnit` int not null,
`PrecioUnit` int not null
)ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS `HOJAP`(
`Idhoja` varchar (10) not null PRIMARY KEY,
`concepto` varchar (100) not null,
`Cantidad` int not null,
`Reparacion` varchar(10) not null,
`Idmec` varchar(10) not null,
FOREIGN KEY (`Idmec`) REFERENCES `MECANICO` (`Idmec`),
FOREIGN KEY (`Reparacion`) REFERENCES `REPUESTO` (`Idrep`)
)ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS `FACTURA`(
`Nofact` varchar(10) not null PRIMARY KEY,
`Fecha` datetime not null,
`Imp_pesos` decimal(2) not null,
`Imp_dol` decimal(2) not null,
`RFC` varchar(10) not null,
`Idhoja` varchar(10) not null,
FOREIGN KEY (`RFC`) REFERENCES CLIENTE (`RFC`),
FOREIGN KEY (`Idhoja`) REFERENCES HOJAP (`Idhoja`)
)ENGINE = InnoDB;
TABLAS DE LA BD
DESCRIPCION TABLA CLIENTE Y VEHICULOCON UN INSERT
DESCRIPCION DE LAS DEMAS TABLAS
JUMM.
No hay comentarios:
Publicar un comentario