-
-
Save parzibyte/272595e79956db87757f18599ec94560 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
CREATE TABLE productos( | |
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, | |
codigo VARCHAR(255) NOT NULL, | |
descripcion VARCHAR(255) NOT NULL, | |
precioVenta DECIMAL(5, 2) NOT NULL, | |
precioCompra DECIMAL(5, 2) NOT NULL, | |
existencia DECIMAL(5, 2) NOT NULL, | |
PRIMARY KEY(id) | |
) ENGINE = InnoDB DEFAULT CHARACTER SET = utf8; | |
CREATE TABLE ventas( | |
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, | |
fecha DATETIME NOT NULL, | |
PRIMARY KEY(id) | |
) ENGINE = InnoDB DEFAULT CHARACTER SET = utf8; | |
CREATE TABLE productos_vendidos( | |
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, | |
id_producto BIGINT UNSIGNED NOT NULL, | |
cantidad BIGINT UNSIGNED NOT NULL, | |
precio DECIMAL(5, 2) NOT NULL, | |
id_venta BIGINT UNSIGNED NOT NULL, | |
PRIMARY KEY(id), | |
FOREIGN KEY(id_producto) REFERENCES productos(id) ON DELETE CASCADE, | |
FOREIGN KEY(id_venta) REFERENCES ventas(id) ON DELETE CASCADE | |
) ENGINE = InnoDB DEFAULT CHARACTER SET = utf8; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment