- Overview
- Features
- Project Structure
- Database Entities
- Key Constraints (Highlights)
- Sample Queries
- How to Run
- Project Objective
- Documentation
- Contributing
- License
This project designs and implements a relational database for managing tax-related information, covering taxpayers, their businesses, tax files, declarations, assessments, inspectors, and tax department offices. It includes conceptual design (ER modeling, keys, cardinalities, integrity constraints), physical implementation (table creation), sample data (initial inserts), and a set of analytical queries.
- Relational database design
- Entity Relationship (ER) modeling
- Primary and Foreign Keys
- Integrity Constraints
- Sample dataset
- SQL queries for data retrieval
- Database normalization concepts
Project
│
├── Code
│ ├── CreateTable
│ ├── InsertTable
│ └── Queries
│
├── Project Instruction
│
├── Report
│
└── README.md
- Taxpayer — Business: N:M → resolved via an associative table (
Business_Tax) - Business — TaxFile: 1:N
- TaxFile — TaxDeclaration: 1:1
- TaxInspector — TaxDeclaration: N:1 (an inspector reviews many declarations)
- TaxInspector — TaxAssessment: 1:N (an inspector issues many assessments)
- TaxDepartment — TaxInspector: 1:N (a department has many inspectors)
Taxpayer.NationalCode:NOT NULL,UNIQUE, length = 10Business.EconomicCode:PRIMARY KEY,NOT NULL,UNIQUETaxFile.EconomicCode:FOREIGN KEY→BusinessTaxDeclaration.TaxFileID,InspectorID:FOREIGN KEYs →TaxFile,TaxInspectorTaxAssessment.TaxAmount: must be> 0TaxDeclaration.TotalIncome,TotalExpense: must be>= 0
- List taxpayers of type 1
- List businesses ordered by registration date
- Show business owners (join Business + Taxpayer)
- Average inspector salary
- Count of inspectors per tax office
- Highest tax amount on record
- Businesses with tax amount greater than 150,000
- Taxpayers whose last name starts with "A"
- Add an
Emailcolumn to theTaxpayertable - Businesses located in Tehran
The files in Code/ are plain .sql scripts, not standalone programs — they need to be executed against a running database instance through a SQL client (e.g., MySQL Workbench, SQL Server Management Studio, DBeaver, psql, or the mysql CLI).
- Open your preferred SQL database system.
- Execute all scripts inside Code/CreateTable.
- Execute all scripts inside Code/InsertTable.
- Execute scripts inside Code/Queries to test the database.
Example using the MySQL CLI:
mysql -u <username> -p <database_name> < Code/CreateTable/create_tables.sql
mysql -u <username> -p <database_name> < Code/InsertTable/insert_data.sql
mysql -u <username> -p <database_name> < Code/Queries/queries.sql
Adjust file names/paths to match what's actually inside each folder, and swap the mysql command for the equivalent tool if you're using a different DBMS (e.g., psql -U <user> -d <database> -f <file>.sql for PostgreSQL).
Run the scripts in the order above — tables reference each other via foreign keys (e.g., Business depends on Taxpayer, TaxFile depends on Business), so creating/populating them out of order will cause constraint errors.
The objective of this project is to design and implement a normalized relational database for a tax management system while applying database design principles, SQL programming, and query development.
See the Report folder for the complete write-up, including the ER diagram description, normalization/key analysis, integrity constraints, full DDL/DML scripts, and query explanations.
Contributions, corrections, and suggestions are welcome. If you'd like to contribute:
- Fork the repository.
- Create a new branch for your change (
git checkout -b feature/your-feature). - Commit your changes with a clear message.
- Open a pull request describing what you changed and why.
Please keep SQL formatting consistent with the existing scripts and update the report/README if you change the schema. you can also reach out via email at rseyednozadi@gmail.com.
This project is licensed under the MIT License. See the LICENSE file for details.
