Note: This project uses synthetic data (fictional CNPJs and values) generated for simulation purposes only. No real fiscal data is stored.
This project focuses on the development of a relational database structure designed to handle fiscal data, specifically focusing on invoice management and ICMS tax calculations.
The goal is to simulate a real-world fiscal environment, managing suppliers and automating the calculation of tax credits and liabilities based on normalized data modeling.
In this project, you will find advanced SQL queries for financial reporting, and strict business rules applied through database constraints.
- Database: MySQL 8.0
- Language: SQL (DDL, DML, DQL)
- Tool: MySQL Workbench
- Version Control: Git & GitHub
icms-control/
├── docs/ # Technical documentation (diagrams and references)
├── sql/ # DDL, DML, and analytical queries
├── screenshots/ # Evidence of execution and database schemas
└── README.md # Project documentationThis diagram represents the current relational model (suppliers and invoices) used in the project.
Clone the project by executing:
git clone https://github.com/SEU_USUARIO/icms-control.gitAccess the project folder:
cd icms-controlRun the scripts in order:
- Create Database:
sql/01-create-database.sql - Create Suppliers Table:
sql/02-create-table-fornecedores.sql - Create Invoices Table:
sql/03-create-table-notas_fiscais.sql - Add Foreign Key:
sql/08-add-FK-notas_fornecedores.sql - Insert Suppliers:
sql/05-insert-fornecedores.sql - Insert Invoices:
sql/06-insert-notas_fiscais.sql - Basic Queries:
sql/07-basic-queries.sql - Analytical Joins & Reports:
sql/09-analytical-joins.sql - (Optional) Monthly ICMS Summary Table:
sql/04-resumo-mensal-icms.sql(structure for monthly close; populate via your ETL/aggregation)
📊 SQL Features & Analysis
- Total ICMS Credit: Calculation per supplier for tax reconciliation.
- Supplier Ranking: Identification of top partners by purchase volume.
- Monthly Summary: Consolidation of tax entries and average rates.
- Aging / Pending Notes: Tracking pending invoices by status.
- ICMS Checks: Notes with ICMS > 0 and ICMS zero/nulo.
- Window Functions: Last invoice per supplier (MySQL 8).
👨💻 Author Edinor de Souza Neto - LinkedIn
