Skip to content

jkeresman01/sqln

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sqln

SQL Schema Normalizer (3NF / BCNF)

A command-line tool for automatic database normalization

Go

What It Does

sqln analyzes a relation defined by its attributes and functional dependencies (FDs),
then automatically decomposes it into normalized relations (tables).

Installation

git clone https://github.com/jkeresman01/sqln.git
cd sqln
go build -o sqln .

Usage

sqln --attrs="<attributes>" --fds="<functional dependencies>" --to=<3NF|BCNF>

Example:

sqln \
  --attrs="PatientID,Name,DOB,ExamID,ExamType,Result,Description,MedicationID,Manufacturer,PrescriptionID,Dosage,Frequency" \
  --fds="PatientID->Name|DOB;ExamID->PatientID|ExamType|Result;ExamType->Description;MedicationID->Name|Manufacturer;PrescriptionID->PatientID|MedicationID|Dosage|Frequency" \
  --to=3NF

Output

              3NF Decomposition
═══════════════════════════════════════════════════════════════════════════
║ Relation  │ Attributes                                                  ║
╠═══════════╪═════════════════════════════════════════════════════════════╣
║ R_1       │ ExamType, Description                                       ║
║ R_2       │ MedicationID, Name, Manufacturer                            ║
║ R_3       │ PrescriptionID, PatientID, MedicationID, Dosage, Frequency  ║
║ R_4       │ PatientID, Name, DOB                                        ║
║ R_5       │ ExamID, PatientID, ExamType, Result                         ║
╚═══════════╧═════════════════════════════════════════════════════════════╝

Project Structure

sqln/
├── cmd/
│   └── root.go          # CLI setup and argument parsing
├── internal/
│   ├── algo/            # Normalization algorithms (closure, keys, decomposition)
│   ├── model/           # Data structures: Relation, FD, AttributeSet
│   └── util/            # Table printer, helpers
└── go.mod

MIT License © 2025 — Josip Keresman

About

SQL database schema normalizer (3NF && BCNF)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages