private void createTables(DBCConnector _db) { var invertedFilesTable = new List <string>(); invertedFilesTable.Add("File_id VARCHAR(50) NOT NULL"); invertedFilesTable.Add("Name VARCHAR(50) NOT NULL"); invertedFilesTable.Add("Author VARCHAR(30)"); invertedFilesTable.Add("CreationYear INT"); invertedFilesTable.Add("Path VARCHAR(200) NOT NULL"); invertedFilesTable.Add("IsAvailable TINYINT(1) NOT NULL"); invertedFilesTable.Add("PRIMARY KEY (File_id)"); _db.CreateTable("Files", invertedFilesTable); var LookupTermsTable = new List <string>(); LookupTermsTable.Add("Term_id INT NOT NULL AUTO_INCREMENT"); LookupTermsTable.Add("Term_txt VARCHAR(30) NOT NULL"); LookupTermsTable.Add("PRIMARY KEY (Term_id)"); _db.CreateTable("LookupTerms", LookupTermsTable); var PostingFileTable = new List <string>(); PostingFileTable.Add("Term_id INT NOT NULL AUTO_INCREMENT"); PostingFileTable.Add("TermName VARCHAR(30) NOT NULL"); PostingFileTable.Add("File_id VARCHAR(50) NOT NULL"); PostingFileTable.Add("Hits INT NOT NULL"); PostingFileTable.Add("PRIMARY KEY (Term_id , File_id)"); PostingFileTable.Add("FOREIGN KEY (File_id) REFERENCES Files(File_id)"); PostingFileTable.Add("FOREIGN KEY (Term_id) REFERENCES LookupTerms(Term_id)"); _db.CreateTable("PostingFile", PostingFileTable); }
//C'tor public DBAccessor() { _db = new DBCConnector(); _db.Initialize(); // createTables(_db); //ONLY at first time }