/// <summary> /// its operation is described by google doc chapter 1 storage, /// if table already exist then ignore the create table operation /// just do the insert value /// </summary> /// <param name="query"></param> private void HandleInsertSqlQuery(SqlInsertQuery query) { // only check prime field table here, is it safe enough ? bool isTableExist = underlineDatabase.CheckIsTableAlreadyExist(query.TableName + "_0"); List <Object> attributes = query.Attributes; int randomVariable = 1; if (!isTableExist) { // table creation operation here createAttributeTables(query, attributes); createPossibleStatesTable(query, attributes); createPossibleWorldsTable(query, attributes); } else { randomVariable = underlineDatabase.GetNextFreeVariableId(query.TableName); if (randomVariable <= 0) { randomVariable = 1; } } // insert value into tables starting here InsertAttributeValue(query, attributes, randomVariable); PopulatePossibleStatesTable(query, randomVariable); PopulatePossibleWorlds(query, randomVariable); }
/// <summary> /// its operation is described by google doc chapter 1 storage, /// if table already exist then ignore the create table operation /// just do the insert value /// </summary> /// <param name="query"></param> public DataTable HandleInsertQuery() { List <object> attributes = query.Attributes; var tableName = query.TableName; int randomVariable = 1; List <string> tNames = GetAttributeTableNames(attributes, query.ColNames, tableName); // table creation operation here CreateAttributeTables(attributes, tableName, query.ColNames, tNames); randomVariable = underlineDatabase.GetNextFreeVariableId(query.TableName); if (randomVariable <= 0) { randomVariable = 1; } // insert value into tables starting here InsertAttributeValue(query.TableName, attributes, randomVariable, tNames); return(null); }