SQL Server Database Reduction Tool
SQL Server Database Reduction Tool
This document outlines the game plan for building the SQL Server Database Reduction Tool,
including all features, technologies, and implementation steps.
📂 Table of Contents
1️⃣ Project Overview
2️⃣ Core Features
3️⃣ Technology Stack
4️⃣ Database Optimization Features
5️⃣ Data Archiving & On-Demand Retrieval
6️⃣ Logging & Monitoring
7️⃣ User Authentication & Role-Based Access
8️⃣ Scheduled Optimizations
9️⃣ Frontend User Interface (React Dashboard)
🔟 Installation & Deployment (Windows Installer & Docker)
✅ Final Steps & Next Actions
📌 Command Used:
sql
CopyEdit
DBCC SHRINKDATABASE (YourDatabase, 10);
✅ Automatically reclaims unused storage.
🔹 Index Optimization
sql
CopyEdit
ALTER INDEX ALL ON YourTable REBUILD;
sql
CopyEdit
DBCC SHRINKFILE (YourDatabase_Log, 1000);
sql
CopyEdit
INSERT INTO EHRDB_Archive.dbo.PatientRecords
SELECT * FROM EHRDB.dbo.PatientRecords
WHERE VisitDate < DATEADD(YEAR, -2, GETDATE());
sql
CopyEdit
INSERT INTO ArchiveRetrievalLog (EventType, TableName, RecordID)
VALUES ('ARCHIVE', 'PatientRecords', 123);
python
CopyEdit
@app.get("/logs")
def get_logs():
cursor.execute("SELECT * FROM ArchiveRetrievalLog ORDER BY Timestamp
DESC")
return cursor.fetchall()
python
CopyEdit
@app.post("/login")
def login(username: str, password: str):
user = get_user(username)
if verify_password(password, user.password):
return {"token": create_jwt_token(username)}
powershell
CopyEdit
$Action = New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-File
run_optimization.ps1"
$Trigger = New-ScheduledTaskTrigger -Weekly -DaysOfWeek Sunday -At 2am
Register-ScheduledTask -TaskName "DB_Optimization" -Action $Action -Trigger
$Trigger
iss
CopyEdit
[Setup]
AppName=SQL Optimizer
OutputDir=.\output
OutputBaseFilename=SQLOptimizerInstaller
[Files]
Source: "backend\*"; DestDir: "{app}"
Source: "frontend\*"; DestDir: "{app}"
Source: "shrink_db.ps1"; DestDir: "{app}"
[Run]
Filename: "{app}\install.bat"; Description: "Install Dependencies"