/** * Database Analyzer * Analyzes database schema and generates documentation */ export interface TableInfo { name: string; columns: ColumnInfo[]; indexes: IndexInfo[]; foreignKeys: ForeignKeyInfo[]; primaryKey: string[]; rowCount?: number; } export interface ColumnInfo { name: string; type: string; nullable: boolean; defaultValue?: string; isPrimaryKey: boolean; isForeignKey: boolean; comment?: string; } export interface IndexInfo { name: string; columns: string[]; isUnique: boolean; type: string; } export interface ForeignKeyInfo { name: string; column: string; referencedTable: string; referencedColumn: string; onDelete?: string; onUpdate?: string; } export interface DatabaseSchema { databaseName: string; databaseType: 'mysql' | 'postgresql' | 'sqlserver' | 'oracle' | 'sqlite'; tables: TableInfo[]; views: string[]; procedures: string[]; triggers: string[]; analyzedAt: string; } export interface RelationshipInfo { fromTable: string; fromColumn: string; toTable: string; toColumn: string; type: 'one-to-one' | 'one-to-many' | 'many-to-many'; } /** * Generate Mermaid ERD from schema */ export declare function generateERD(schema: DatabaseSchema): string; /** * Generate Data Dictionary markdown */ export declare function generateDataDictionary(schema: DatabaseSchema): string; /** * Analyze relationships between tables */ export declare function analyzeRelationships(schema: DatabaseSchema): RelationshipInfo[]; /** * Extract business entities from schema */ export declare function extractBusinessEntities(schema: DatabaseSchema): string[]; /** * Generate database schema markdown */ export declare function generateSchemaMarkdown(schema: DatabaseSchema): string; export declare class DatabaseAnalyzer { /** * Parse SQL schema file and extract structure */ parseSchemaSQL(sql: string, dbType?: 'mysql' | 'postgresql'): DatabaseSchema; /** * Parse table definition */ private parseTableDefinition; /** * Generate all documentation from schema */ generateDocumentation(schema: DatabaseSchema): { schemaMarkdown: string; dataDictionary: string; erdDiagram: string; }; }