Created
November 28, 2015 04:40
-
-
Save rcotrina94/ec1c07ad151793a92a63 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BEGIN; | |
CREATE TABLE `sistema_categoriatipovino` ( | |
`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, | |
`nombre` varchar(64) NOT NULL | |
) | |
; | |
CREATE TABLE `sistema_tipovino` ( | |
`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, | |
`categoria_id` integer, | |
`anada` integer UNSIGNED NOT NULL, | |
`temperatura` integer UNSIGNED NOT NULL, | |
`comentarios_vino` longtext NOT NULL, | |
`bodega_id` integer NOT NULL | |
) | |
; | |
ALTER TABLE `sistema_tipovino` ADD CONSTRAINT `categoria_id_refs_id_406039d7` FOREIGN KEY (`categoria_id`) REFERENCES `sistema_categoriatipovino` (`id`); | |
CREATE TABLE `sistema_formato` ( | |
`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, | |
`volumen` integer UNSIGNED NOT NULL | |
) | |
; | |
CREATE TABLE `sistema_bodega` ( | |
`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, | |
`nombre` varchar(64) NOT NULL, | |
`direccion` varchar(128) NOT NULL, | |
`telefono` varchar(9) NOT NULL, | |
`correo` varchar(254) NOT NULL | |
) | |
; | |
ALTER TABLE `sistema_tipovino` ADD CONSTRAINT `bodega_id_refs_id_69e7c4d6` FOREIGN KEY (`bodega_id`) REFERENCES `sistema_bodega` (`id`); | |
CREATE TABLE `sistema_imagenproducto` ( | |
`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, | |
`producto_id` integer NOT NULL, | |
`imagen` varchar(100) NOT NULL | |
) | |
; | |
CREATE TABLE `sistema_producto` ( | |
`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, | |
`descripcion` longtext NOT NULL, | |
`foto` varchar(100) NOT NULL, | |
`precio` numeric(8, 2) NOT NULL, | |
`created_at` datetime(6) NOT NULL, | |
`updated_at` datetime(6) NOT NULL | |
) | |
; | |
ALTER TABLE `sistema_imagenproducto` ADD CONSTRAINT `producto_id_refs_id_ac71b86f` FOREIGN KEY (`producto_id`) REFERENCES `sistema_producto` (`id`); | |
CREATE TABLE `sistema_botella` ( | |
`producto_ptr_id` integer NOT NULL PRIMARY KEY, | |
`vino_id` integer NOT NULL, | |
`etiquetado` varchar(64) NOT NULL | |
) | |
; | |
ALTER TABLE `sistema_botella` ADD CONSTRAINT `producto_ptr_id_refs_id_e2ad81b1` FOREIGN KEY (`producto_ptr_id`) REFERENCES `sistema_producto` (`id`); | |
CREATE TABLE `sistema_tipocaja` ( | |
`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, | |
`nombre` varchar(64) NOT NULL, | |
`descripcion` longtext NOT NULL | |
) | |
; | |
CREATE TABLE `sistema_caja` ( | |
`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, | |
`tipo_id` integer NOT NULL, | |
`descripcion` longtext NOT NULL, | |
`precio` numeric(8, 2) NOT NULL | |
) | |
; | |
ALTER TABLE `sistema_caja` ADD CONSTRAINT `tipo_id_refs_id_6137c20d` FOREIGN KEY (`tipo_id`) REFERENCES `sistema_tipocaja` (`id`); | |
CREATE TABLE `sistema_cajabotellas` ( | |
`producto_ptr_id` integer NOT NULL PRIMARY KEY, | |
`n_botellas` integer UNSIGNED NOT NULL, | |
`caja_id` integer NOT NULL, | |
`botella_id` integer NOT NULL | |
) | |
; | |
ALTER TABLE `sistema_cajabotellas` ADD CONSTRAINT `botella_id_refs_producto_ptr_id_f5422d18` FOREIGN KEY (`botella_id`) REFERENCES `sistema_botella` (`producto_ptr_id`); | |
ALTER TABLE `sistema_cajabotellas` ADD CONSTRAINT `producto_ptr_id_refs_id_3b3bdced` FOREIGN KEY (`producto_ptr_id`) REFERENCES `sistema_producto` (`id`); | |
ALTER TABLE `sistema_cajabotellas` ADD CONSTRAINT `caja_id_refs_id_31859c47` FOREIGN KEY (`caja_id`) REFERENCES `sistema_caja` (`id`); | |
CREATE TABLE `sistema_detallepedido` ( | |
`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, | |
`pedido_id` integer NOT NULL, | |
`producto_id` integer NOT NULL, | |
`cantidad` integer UNSIGNED NOT NULL | |
) | |
; | |
ALTER TABLE `sistema_detallepedido` ADD CONSTRAINT `producto_id_refs_id_7a430102` FOREIGN KEY (`producto_id`) REFERENCES `sistema_producto` (`id`); | |
CREATE TABLE `sistema_pedido` ( | |
`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, | |
`fecha` datetime(6) NOT NULL | |
) | |
; | |
ALTER TABLE `sistema_detallepedido` ADD CONSTRAINT `pedido_id_refs_id_625a96f7` FOREIGN KEY (`pedido_id`) REFERENCES `sistema_pedido` (`id`); | |
CREATE TABLE `sistema_factura` ( | |
`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, | |
`fecha` datetime(6) NOT NULL, | |
`pedido_id` integer NOT NULL | |
) | |
; | |
ALTER TABLE `sistema_factura` ADD CONSTRAINT `pedido_id_refs_id_8bd9990e` FOREIGN KEY (`pedido_id`) REFERENCES `sistema_pedido` (`id`); | |
CREATE TABLE `sistema_particular` ( | |
`login_id` integer NOT NULL PRIMARY KEY, | |
`dni` varchar(8) NOT NULL UNIQUE, | |
`fecha_nacimiento` date NOT NULL, | |
`nombre` varchar(32) NOT NULL, | |
`apellido1` varchar(32) NOT NULL, | |
`apellido2` varchar(32) NOT NULL, | |
`direccion` varchar(128) NOT NULL | |
) | |
; | |
ALTER TABLE `sistema_particular` ADD CONSTRAINT `login_id_refs_id_1bd306da` FOREIGN KEY (`login_id`) REFERENCES `auth_user` (`id`); | |
CREATE TABLE `sistema_empresa` ( | |
`login_id` integer NOT NULL PRIMARY KEY, | |
`RUC` varchar(12) NOT NULL, | |
`nombre` varchar(64) NOT NULL, | |
`direccion` varchar(128) NOT NULL | |
) | |
; | |
ALTER TABLE `sistema_empresa` ADD CONSTRAINT `login_id_refs_id_0ca59fe4` FOREIGN KEY (`login_id`) REFERENCES `auth_user` (`id`); | |
CREATE TABLE `sistema_telefono` ( | |
`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, | |
`numero` varchar(9) NOT NULL | |
) | |
; | |
CREATE TABLE `sistema_vino` ( | |
`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, | |
`formato_id` integer NOT NULL, | |
`tipo_vino_id` integer NOT NULL | |
) | |
; | |
ALTER TABLE `sistema_vino` ADD CONSTRAINT `formato_id_refs_id_a118adfa` FOREIGN KEY (`formato_id`) REFERENCES `sistema_formato` (`id`); | |
ALTER TABLE `sistema_vino` ADD CONSTRAINT `tipo_vino_id_refs_id_2ecf4681` FOREIGN KEY (`tipo_vino_id`) REFERENCES `sistema_tipovino` (`id`); | |
ALTER TABLE `sistema_botella` ADD CONSTRAINT `vino_id_refs_id_e07899c5` FOREIGN KEY (`vino_id`) REFERENCES `sistema_vino` (`id`); | |
CREATE INDEX `sistema_categoriatipovino_aa17bc3d` ON `sistema_categoriatipovino` (`nombre`); | |
CREATE INDEX `sistema_tipovino_5f2644f7` ON `sistema_tipovino` (`categoria_id`); | |
CREATE INDEX `sistema_tipovino_3616b3ce` ON `sistema_tipovino` (`anada`); | |
CREATE INDEX `sistema_tipovino_fdf90f60` ON `sistema_tipovino` (`temperatura`); | |
CREATE INDEX `sistema_tipovino_97b7780a` ON `sistema_tipovino` (`bodega_id`); | |
CREATE INDEX `sistema_formato_dd518c5c` ON `sistema_formato` (`volumen`); | |
CREATE INDEX `sistema_bodega_aa17bc3d` ON `sistema_bodega` (`nombre`); | |
CREATE INDEX `sistema_imagenproducto_1635d9bd` ON `sistema_imagenproducto` (`producto_id`); | |
CREATE INDEX `sistema_producto_3810ba66` ON `sistema_producto` (`precio`); | |
CREATE INDEX `sistema_producto_96511a37` ON `sistema_producto` (`created_at`); | |
CREATE INDEX `sistema_producto_a11a40ab` ON `sistema_producto` (`updated_at`); | |
CREATE INDEX `sistema_botella_84c74cc8` ON `sistema_botella` (`vino_id`); | |
CREATE INDEX `sistema_tipocaja_aa17bc3d` ON `sistema_tipocaja` (`nombre`); | |
CREATE INDEX `sistema_caja_acf1eac4` ON `sistema_caja` (`tipo_id`); | |
CREATE INDEX `sistema_caja_3810ba66` ON `sistema_caja` (`precio`); | |
CREATE INDEX `sistema_cajabotellas_f005beae` ON `sistema_cajabotellas` (`caja_id`); | |
CREATE INDEX `sistema_cajabotellas_dc79d9c1` ON `sistema_cajabotellas` (`botella_id`); | |
CREATE INDEX `sistema_detallepedido_7cb5251d` ON `sistema_detallepedido` (`pedido_id`); | |
CREATE INDEX `sistema_detallepedido_1635d9bd` ON `sistema_detallepedido` (`producto_id`); | |
CREATE INDEX `sistema_factura_7cb5251d` ON `sistema_factura` (`pedido_id`); | |
CREATE INDEX `sistema_particular_aa17bc3d` ON `sistema_particular` (`nombre`); | |
CREATE INDEX `sistema_particular_46fd711f` ON `sistema_particular` (`apellido1`); | |
CREATE INDEX `sistema_particular_31bd45d4` ON `sistema_particular` (`apellido2`); | |
CREATE INDEX `sistema_particular_03da2bf8` ON `sistema_particular` (`direccion`); | |
CREATE INDEX `sistema_empresa_ed9e77c9` ON `sistema_empresa` (`RUC`); | |
CREATE INDEX `sistema_empresa_aa17bc3d` ON `sistema_empresa` (`nombre`); | |
CREATE INDEX `sistema_empresa_03da2bf8` ON `sistema_empresa` (`direccion`); | |
CREATE INDEX `sistema_telefono_a31d40fc` ON `sistema_telefono` (`numero`); | |
CREATE INDEX `sistema_vino_ad87ccf3` ON `sistema_vino` (`formato_id`); | |
CREATE INDEX `sistema_vino_ddc671f4` ON `sistema_vino` (`tipo_vino_id`); | |
COMMIT; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment