This project contains the SQL Server database schema for ElectroConecta, a company that sells electronic products. The database is designed to handle various aspects of the business, including customers, employees, inventory, and sales transactions.
The database consists of the following main tables:
-
DISTRITOS: Stores district information.
ID_distrito
(CHAR(3)): Primary Keynombre_distrito
(VARCHAR(40)): Name of the district
-
TRABAJADOR: Stores employee information.
DNI_trabajador
(CHAR(8)): Primary Keynombres_tra
(VARCHAR(25)): First names of the employeeapellidos_tra
(VARCHAR(25)): Last names of the employeedireccion_tra
(VARCHAR(60)): Address of the employeeedad
(INT): Age of the employeetelefono_tra
(VARCHAR(12)): Phone number of the employeeemail_tra
(VARCHAR(35)): Email of the employeesueldo
(MONEY): Salary of the employeefecha_inicio_contrato
(DATE): Contract start datefecha_final_contrato
(DATE): Contract end dateID_distrito
(CHAR(3)): Foreign Key referencingDISTRITOS
-
CLIENTE: Stores customer information.
DNI_cliente
(CHAR(8)): Primary Keynombres_cli
(VARCHAR(25)): First names of the customerapellidos_cli
(VARCHAR(25)): Last names of the customerdireccion_cli
(VARCHAR(60)): Address of the customertelefono_cli
(CHAR(9)): Phone number of the customeremail_cli
(VARCHAR(35)): Email of the customerID_distrito
(CHAR(3)): Foreign Key referencingDISTRITOS
-
ALMACEN: Stores warehouse information.
cod_almacen
(CHAR(7)): Primary KeyID_distrito
(CHAR(3)): Foreign Key referencingDISTRITOS
direccion
(VARCHAR(60)): Address of the warehousearea_m2
(DECIMAL(8,2)): Area of the warehouse in square meterscant_pisos
(INT): Number of floors in the warehouse
-
ALMACENERO: Stores warehouse manager information.
cod_almacenero
(CHAR(7)): Primary Keycod_almacen
(CHAR(7)): Foreign Key referencingALMACEN
DNI_trabajador
(CHAR(8)): Foreign Key referencingTRABAJADOR
-
TRANSPORTE: Stores transport vehicle information.
placa
(VARCHAR(7)): Primary Keycapacidad_carga
(CHAR(5)): Load capacity of the vehiclemodelo
(VARCHAR(12)): Model of the vehicledimencion_alt_m
(DECIMAL(2,2)): Height of the vehicle in metersdimencion_ancho_m
(DECIMAL(2,2)): Width of the vehicle in metersdimencion_largo_m
(DECIMAL(2,2)): Length of the vehicle in meterspeso_vehiculo_kg
(DECIMAL(8,2)): Weight of the vehicle in kilograms
-
TRANSPORTISTA: Stores transport driver information.
cod_transportista
(CHAR(7)): Primary Keyplaca
(VARCHAR(7)): Foreign Key referencingTRANSPORTE
DNI_trabajador
(CHAR(8)): Foreign Key referencingTRABAJADOR
-
VENDEDOR: Stores salesperson information.
cod_vendedor
(CHAR(7)): Primary KeyDNI_trabajador
(CHAR(8)): Foreign Key referencingTRABAJADOR
-
VENTA: Stores sales transaction information.
num_venta
(CHAR(8)): Primary Keyfecha_emision
(DATE): Date of issuanceDNI_cliente
(CHAR(8)): Foreign Key referencingCLIENTE
cod_vendedor
(CHAR(7)): Foreign Key referencingVENDEDOR
IGV
(DECIMAL(4,2)): Taxsub_total
(DECIMAL(8,2)): Subtotal amountTotal
(DECIMAL(8,2)): Total amount
-
PRODUCTO: Stores product information.
ID_producto
(CHAR(6)): Primary Keynombre_producto
(VARCHAR(35)): Name of the productprecio
(MONEY): Price of the productID_categoria
(CHAR(3)): Foreign Key referencingCATEGORIA
stock
(INT): Stock quantitymarca
(VARCHAR(25)): Brand of the product
-
DETALLE_VENTA: Stores sales detail information.
num_venta
(CHAR(8)): Foreign Key referencingVENTA
ID_producto
(CHAR(6)): Foreign Key referencingPRODUCTO
cantidad
(INT): Quantity of the product soldprecio_venta
(MONEY): Sale price of the product
To set up the database, run the SQL script provided in the repository. Ensure you have SQL Server installed and configured.
-
Create the database:
CREATE DATABASE PROYECTO_BASE_DATOS_EDIT1;
-
Use the database:
USE PROYECTO_BASE_DATOS_EDIT1;
-
Create tables:
-- Example of creating the DISTRITOS table CREATE TABLE DISTRITOS ( ID_distrito CHAR(3) NOT NULL PRIMARY KEY, nombre_distrito VARCHAR(40) NOT NULL );
-
Insert data as required for your application.
Contributions are welcome! Please fork the repository and submit pull requests for any enhancements or bug fixes.