0% found this document useful (0 votes)
26 views2 pages

HeidiSQL Code

The document contains SQL code to create a database named 'lucila_store' with several tables including PRODUCTS, CLIENTS, SUPPLIERS, BRANCHES, SALES, SALES_DETAIL, and BITACORA. Each table has defined columns with data types and primary keys, but some columns are missing data types or have syntax errors. The code aims to establish a structured database for managing products, clients, suppliers, branches, and sales transactions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views2 pages

HeidiSQL Code

The document contains SQL code to create a database named 'lucila_store' with several tables including PRODUCTS, CLIENTS, SUPPLIERS, BRANCHES, SALES, SALES_DETAIL, and BITACORA. Each table has defined columns with data types and primary keys, but some columns are missing data types or have syntax errors. The code aims to establish a structured database for managing products, clients, suppliers, branches, and sales transactions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

HeidiSQL code

CREATE DATABASE `lucila_store`;

USE `store`;

CREATE TABLE `PRODUCTS` (


`product_id` INT NOT NULL AUTO_INCREMENT,
name VARCHAR(255) NOT NULL
TEXT
DECIMAL(10,2) NOT NULL
`stock` INT NOT NULL,
PRIMARY KEY (`product_id`)
);

CREATE TABLE `CLIENTS` (


`client_id` INT NOT NULL AUTO_INCREMENT,
name VARCHAR(255) NOT NULL
last_name VARCHAR(255) NOT NULL
email
phone_number
PRIMARY KEY (`client_id`)
);

CREATE TABLE `SUPPLIERS` (


`supplier_id` INT NOT NULL AUTO_INCREMENT,
name VARCHAR(255) NOT NULL
address
email
phone_number
PRIMARY KEY (`supplier_id`)
);

CREATE TABLE `BRANCHES` (


`branch_id` INT NOT NULL AUTO_INCREMENT,
`name` VARCHAR(255) NOT NULL,
address
phone_number
PRIMARY KEY (`id_branch`)
);

CREATE TABLE `SALES` (


INT NOT NULL AUTO_INCREMENT
sale_date
`client_id` INT NOT NULL,
branch_id INT NOT NULL,
PRIMARY KEY (`sale_id`),
FOREIGN KEY (`id_cliente`) REFERENCES `CLIENTS` (`id_cliente`),
FOREIGN KEY (`id_branch`) REFERENCES `BRANCHES` (`id_branch`)
);

CREATE TABLE `SALES_DETAIL` (


id_sale_detail INT NOT NULL AUTO_INCREMENT,
sale_id
INT NOT NULL
quantity INT NOT NULL
DECIMAL(10,2) NOT NULL
PRIMARY KEY (`id_detail_sale`)
FOREIGN KEY (`id_venta`) REFERENCES `VENTAS` (`id_venta`),
FOREIGN KEY (`id_producto`) REFERENCES `PRODUCTOS` (`id_producto`)
);

CREATE TABLE `BITACORA` (


id_bitacora INT NOT NULL AUTO_INCREMENT,
`user_id` VARCHAR(255) NOT NULL,
`action` VARCHAR(255) NOT NULL,
datetime not null
PRIMARY KEY (`id_bitacora`)
);

You might also like