From 21d678c1852cbccc1986e39e9456344e4908a80d Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Fri, 20 Apr 2018 22:09:33 +0100 Subject: [PATCH] Update database to version 10 (add fields to processors, add instruction set and extensions) --- Cicm.Database/Operations/Init.cs | 62 ++-- Cicm.Database/Operations/InstructionSet.cs | 285 +++++++++++++++ .../Operations/InstructionSetExtension.cs | 324 ++++++++++++++++++ Cicm.Database/Operations/Operations.cs | 2 +- Cicm.Database/Operations/Processor.cs | 150 +++++++- Cicm.Database/Operations/Update.cs | 119 +++++++ Cicm.Database/Schemas/InstructionSet.cs | 40 +++ .../Schemas/InstructionSetExtension.cs | 40 +++ Cicm.Database/Schemas/Processor.cs | 55 +++ Cicm.Database/Schemas/Sql/V10.cs | 168 +++++++++ cicm_web/cicm_web.csproj | 2 +- 11 files changed, 1214 insertions(+), 33 deletions(-) create mode 100644 Cicm.Database/Operations/InstructionSet.cs create mode 100644 Cicm.Database/Operations/InstructionSetExtension.cs create mode 100644 Cicm.Database/Schemas/InstructionSet.cs create mode 100644 Cicm.Database/Schemas/InstructionSetExtension.cs create mode 100644 Cicm.Database/Schemas/Sql/V10.cs diff --git a/Cicm.Database/Operations/Init.cs b/Cicm.Database/Operations/Init.cs index 5357ca33..760479e1 100644 --- a/Cicm.Database/Operations/Init.cs +++ b/Cicm.Database/Operations/Init.cs @@ -49,95 +49,111 @@ namespace Cicm.Database IDbCommand dbCmd = dbCon.CreateCommand(); Console.WriteLine("Creating table `admins`"); - dbCmd.CommandText = V8.Admins; + dbCmd.CommandText = V10.Admins; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `browser_tests`"); - dbCmd.CommandText = V8.BrowserTests; + dbCmd.CommandText = V10.BrowserTests; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `cicm_db`"); - dbCmd.CommandText = V8.CicmDb; + dbCmd.CommandText = V10.CicmDb; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `companies`"); - dbCmd.CommandText = V8.Companies; + dbCmd.CommandText = V10.Companies; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `computers`"); - dbCmd.CommandText = V8.Computers; + dbCmd.CommandText = V10.Computers; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `consoles`"); - dbCmd.CommandText = V8.Consoles; + dbCmd.CommandText = V10.Consoles; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `disk_formats`"); - dbCmd.CommandText = V8.DiskFormats; + dbCmd.CommandText = V10.DiskFormats; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `forbidden`"); - dbCmd.CommandText = V8.Forbidden; + dbCmd.CommandText = V10.Forbidden; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `gpus`"); - dbCmd.CommandText = V8.Gpus; + dbCmd.CommandText = V10.Gpus; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `log`"); - dbCmd.CommandText = V8.Logs; + dbCmd.CommandText = V10.Logs; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `money_donations`"); - dbCmd.CommandText = V8.MoneyDonations; + dbCmd.CommandText = V10.MoneyDonations; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `music_synths`"); - dbCmd.CommandText = V8.MusicSynths; + dbCmd.CommandText = V10.MusicSynths; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `news`"); - dbCmd.CommandText = V8.News; + dbCmd.CommandText = V10.News; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `owned_computers`"); - dbCmd.CommandText = V8.OwnedComputers; + dbCmd.CommandText = V10.OwnedComputers; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `owned_consoles`"); - dbCmd.CommandText = V8.OwnedConsoles; + dbCmd.CommandText = V10.OwnedConsoles; + dbCmd.ExecuteNonQuery(); + + Console.WriteLine("Creating table `instruction_sets`"); + dbCmd.CommandText = V10.InstructionSets; + dbCmd.ExecuteNonQuery(); + + Console.WriteLine("Creating table `instruction_set_extensions`"); + dbCmd.CommandText = V10.InstructionSetExtensions; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `processors`"); - dbCmd.CommandText = V8.Processors; + dbCmd.CommandText = V10.Processors; + dbCmd.ExecuteNonQuery(); + + Console.WriteLine("Creating table `instruction_set_extensions_by_processor`"); + dbCmd.CommandText = V10.InstructionSetExtensionsByProcessor; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `sound_synths`"); - dbCmd.CommandText = V8.SoundSynths; + dbCmd.CommandText = V10.SoundSynths; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `iso3166_1_numeric`"); - dbCmd.CommandText = V8.Iso3166Numeric; + dbCmd.CommandText = V10.Iso3166Numeric; dbCmd.ExecuteNonQuery(); Console.WriteLine("Filling table `iso3166_1_numeric`"); - dbCmd.CommandText = V8.Iso3166NumericValues; + dbCmd.CommandText = V10.Iso3166NumericValues; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating foreign keys for table `companies`"); - dbCmd.CommandText = V8.CompaniesForeignKeys; + dbCmd.CommandText = V10.CompaniesForeignKeys; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating foreign keys for table `computers`"); - dbCmd.CommandText = V8.ComputersForeignKeys; + dbCmd.CommandText = V10.ComputersForeignKeys; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating foreign keys for table `consoles`"); - dbCmd.CommandText = V8.ConsolesForeignKeys; + dbCmd.CommandText = V10.ConsolesForeignKeys; dbCmd.ExecuteNonQuery(); Console.WriteLine("Creating table `company_logos`"); - dbCmd.CommandText = V8.CompanyLogos; + dbCmd.CommandText = V10.CompanyLogos; + dbCmd.ExecuteNonQuery(); + + Console.WriteLine("Creating table `company_descriptions`"); + dbCmd.CommandText = V10.CompanyDescriptions; dbCmd.ExecuteNonQuery(); return true; diff --git a/Cicm.Database/Operations/InstructionSet.cs b/Cicm.Database/Operations/InstructionSet.cs new file mode 100644 index 00000000..a3a4e077 --- /dev/null +++ b/Cicm.Database/Operations/InstructionSet.cs @@ -0,0 +1,285 @@ +/****************************************************************************** +// Canary Islands Computer Museum Website +// ---------------------------------------------------------------------------- +// +// Filename : InstructionSet.cs +// Author(s) : Natalia Portillo +// +// --[ Description ] ---------------------------------------------------------- +// +// Contains operations to manage instruction_sets. +// +// --[ License ] -------------------------------------------------------------- +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// ---------------------------------------------------------------------------- +// Copyright © 2003-2018 Natalia Portillo +*******************************************************************************/ + +using System; +using System.Collections.Generic; +using System.Data; +using Cicm.Database.Schemas; +using Console = System.Console; + +namespace Cicm.Database +{ + public partial class Operations + { + /// + /// Gets all instruction sets + /// + /// All instruction sets + /// true if is correct, false otherwise + public bool GetInstructionSets(out List entries) + { + #if DEBUG + Console.WriteLine("Getting all instruction sets..."); + #endif + + try + { + const string SQL = "SELECT * from instruction_sets"; + + IDbCommand dbCmd = dbCon.CreateCommand(); + IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter(); + dbCmd.CommandText = SQL; + DataSet dataSet = new DataSet(); + dataAdapter.SelectCommand = dbCmd; + dataAdapter.Fill(dataSet); + + entries = InstructionSetsFromDataTable(dataSet.Tables[0]); + + return true; + } + catch(Exception ex) + { + Console.WriteLine("Error getting instruction sets."); + Console.WriteLine(ex); + entries = null; + return false; + } + } + + /// + /// Gets the specified number of instruction sets since the specified start + /// + /// List of instruction sets + /// Start of query + /// How many entries to retrieve + /// true if is correct, false otherwise + public bool GetInstructionSets(out List entries, ulong start, ulong count) + { + #if DEBUG + Console.WriteLine("Getting {0} instruction sets from {1}...", count, start); + #endif + + try + { + string sql = $"SELECT * FROM instruction_sets LIMIT {start}, {count}"; + + IDbCommand dbCmd = dbCon.CreateCommand(); + IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter(); + dbCmd.CommandText = sql; + DataSet dataSet = new DataSet(); + dataAdapter.SelectCommand = dbCmd; + dataAdapter.Fill(dataSet); + + entries = InstructionSetsFromDataTable(dataSet.Tables[0]); + + return true; + } + catch(Exception ex) + { + Console.WriteLine("Error getting instruction sets."); + Console.WriteLine(ex); + entries = null; + return false; + } + } + + /// + /// Gets instruction set by specified id + /// + /// Id + /// InstructionSet with specified id, null if not found or error + public InstructionSet GetInstructionSet(int id) + { + #if DEBUG + Console.WriteLine("Getting instruction set with id {0}...", id); + #endif + + try + { + string sql = $"SELECT * from instruction_sets WHERE id = '{id}'"; + + IDbCommand dbCmd = dbCon.CreateCommand(); + IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter(); + dbCmd.CommandText = sql; + DataSet dataSet = new DataSet(); + dataAdapter.SelectCommand = dbCmd; + dataAdapter.Fill(dataSet); + + List entries = InstructionSetsFromDataTable(dataSet.Tables[0]); + + return entries == null || entries.Count == 0 ? null : entries[0]; + } + catch(Exception ex) + { + Console.WriteLine("Error getting instruction set."); + Console.WriteLine(ex); + return null; + } + } + + /// + /// Counts the number of instruction sets in the database + /// + /// Entries in database + public long CountInstructionSets() + { + #if DEBUG + Console.WriteLine("Counting instruction_sets..."); + #endif + + IDbCommand dbcmd = dbCon.CreateCommand(); + dbcmd.CommandText = "SELECT COUNT(*) FROM instruction_sets"; + object count = dbcmd.ExecuteScalar(); + dbcmd.Dispose(); + try { return Convert.ToInt64(count); } + catch { return 0; } + } + + /// + /// Adds a new instruction set to the database + /// + /// Entry to add + /// ID of added entry + /// true if added correctly, false otherwise + public bool AddInstructionSet(InstructionSet entry, out long id) + { + #if DEBUG + Console.Write("Adding instruction set `{0}`...", entry.Name); + #endif + + IDbCommand dbcmd = GetCommandInstructionSet(entry); + IDbTransaction trans = dbCon.BeginTransaction(); + dbcmd.Transaction = trans; + + const string SQL = "INSERT INTO instruction_sets (instruction_set) VALUES (@instruction_set)"; + + dbcmd.CommandText = SQL; + + dbcmd.ExecuteNonQuery(); + trans.Commit(); + dbcmd.Dispose(); + + id = dbCore.LastInsertRowId; + + #if DEBUG + Console.WriteLine(" id {0}", id); + #endif + + return true; + } + + /// + /// Updated a instruction set in the database + /// + /// Updated entry + /// true if updated correctly, false otherwise + public bool UpdateInstructionSet(InstructionSet entry) + { + #if DEBUG + Console.WriteLine("Updating instruction set `{0}`...", entry.Name); + #endif + + IDbCommand dbcmd = GetCommandInstructionSet(entry); + IDbTransaction trans = dbCon.BeginTransaction(); + dbcmd.Transaction = trans; + + string sql = "UPDATE instruction_sets SET instruction_set = @instruction_set " + $"WHERE id = {entry.Id}"; + + dbcmd.CommandText = sql; + + dbcmd.ExecuteNonQuery(); + trans.Commit(); + dbcmd.Dispose(); + + return true; + } + + /// + /// Removes a instruction set from the database + /// + /// ID of entry to remove + /// true if removed correctly, false otherwise + public bool RemoveInstructionSet(long id) + { + #if DEBUG + Console.WriteLine("Removing instruction set widh id `{0}`...", id); + #endif + + IDbCommand dbcmd = dbCon.CreateCommand(); + IDbTransaction trans = dbCon.BeginTransaction(); + dbcmd.Transaction = trans; + + string sql = $"DELETE FROM instruction_sets WHERE id = '{id}';"; + + dbcmd.CommandText = sql; + + dbcmd.ExecuteNonQuery(); + trans.Commit(); + dbcmd.Dispose(); + + return true; + } + + IDbCommand GetCommandInstructionSet(InstructionSet entry) + { + IDbCommand dbcmd = dbCon.CreateCommand(); + + IDbDataParameter param1 = dbcmd.CreateParameter(); + + param1.ParameterName = "@instruction_set"; + + param1.DbType = DbType.String; + + param1.Value = entry.Name; + + dbcmd.Parameters.Add(param1); + + return dbcmd; + } + + static List InstructionSetsFromDataTable(DataTable dataTable) + { + List entries = new List(); + + foreach(DataRow dataRow in dataTable.Rows) + { + InstructionSet entry = new InstructionSet + { + Id = int.Parse(dataRow["id"].ToString()), + Name = dataRow["instruction_set"].ToString() + }; + + entries.Add(entry); + } + + return entries; + } + } +} \ No newline at end of file diff --git a/Cicm.Database/Operations/InstructionSetExtension.cs b/Cicm.Database/Operations/InstructionSetExtension.cs new file mode 100644 index 00000000..92f6d362 --- /dev/null +++ b/Cicm.Database/Operations/InstructionSetExtension.cs @@ -0,0 +1,324 @@ +/****************************************************************************** +// Canary Islands Computer Museum Website +// ---------------------------------------------------------------------------- +// +// Filename : InstructionSet.cs +// Author(s) : Natalia Portillo +// +// --[ Description ] ---------------------------------------------------------- +// +// Contains operations to manage instruction_set_extensions. +// +// --[ License ] -------------------------------------------------------------- +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// ---------------------------------------------------------------------------- +// Copyright © 2003-2018 Natalia Portillo +*******************************************************************************/ + +using System; +using System.Collections.Generic; +using System.Data; +using Cicm.Database.Schemas; +using Console = System.Console; + +namespace Cicm.Database +{ + public partial class Operations + { + /// + /// Gets all instruction set extensions + /// + /// All instruction set extensions + /// true if is correct, false otherwise + public bool GetInstructionSetExtensions(out List entries) + { + #if DEBUG + Console.WriteLine("Getting all instruction set extensions..."); + #endif + + try + { + const string SQL = "SELECT * from instruction_set_extensions"; + + IDbCommand dbCmd = dbCon.CreateCommand(); + IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter(); + dbCmd.CommandText = SQL; + DataSet dataSet = new DataSet(); + dataAdapter.SelectCommand = dbCmd; + dataAdapter.Fill(dataSet); + + entries = InstructionSetExtensionsFromDataTable(dataSet.Tables[0]); + + return true; + } + catch(Exception ex) + { + Console.WriteLine("Error getting instruction set extensions."); + Console.WriteLine(ex); + entries = null; + return false; + } + } + + /// + /// Gets the specified number of instruction set extensions since the specified start + /// + /// List of instruction set extensions + /// Start of query + /// How many entries to retrieve + /// true if is correct, false otherwise + public bool GetInstructionSetExtensions(out List entries, ulong start, ulong count) + { + #if DEBUG + Console.WriteLine("Getting {0} instruction set extensions from {1}...", count, start); + #endif + + try + { + string sql = $"SELECT * FROM instruction_set_extensions LIMIT {start}, {count}"; + + IDbCommand dbCmd = dbCon.CreateCommand(); + IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter(); + dbCmd.CommandText = sql; + DataSet dataSet = new DataSet(); + dataAdapter.SelectCommand = dbCmd; + dataAdapter.Fill(dataSet); + + entries = InstructionSetExtensionsFromDataTable(dataSet.Tables[0]); + + return true; + } + catch(Exception ex) + { + Console.WriteLine("Error getting instruction set extensions."); + Console.WriteLine(ex); + entries = null; + return false; + } + } + + /// + /// Gets instruction set extension by specified id + /// + /// Id + /// InstructionSet with specified id, null if not found or error + public InstructionSetExtension GetInstructionSetExtension(int id) + { + #if DEBUG + Console.WriteLine("Getting instruction set extension with id {0}...", id); + #endif + + try + { + string sql = $"SELECT * from instruction_set_extensions WHERE id = '{id}'"; + + IDbCommand dbCmd = dbCon.CreateCommand(); + IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter(); + dbCmd.CommandText = sql; + DataSet dataSet = new DataSet(); + dataAdapter.SelectCommand = dbCmd; + dataAdapter.Fill(dataSet); + + List entries = InstructionSetExtensionsFromDataTable(dataSet.Tables[0]); + + return entries == null || entries.Count == 0 ? null : entries[0]; + } + catch(Exception ex) + { + Console.WriteLine("Error getting instruction set extension."); + Console.WriteLine(ex); + return null; + } + } + + public List GetInstructionSetExtensions(int processor) + { + #if DEBUG + Console.WriteLine("Getting instruction set extension for processor id {0}...", processor); + #endif + + try + { + string sql = + $"SELECT * from instruction_set_extensions_by_processor WHERE processor_id = '{processor}'"; + + IDbCommand dbCmd = dbCon.CreateCommand(); + IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter(); + dbCmd.CommandText = sql; + DataSet dataSet = new DataSet(); + dataAdapter.SelectCommand = dbCmd; + dataAdapter.Fill(dataSet); + + if(dataSet.Tables[0].Rows.Count == 0) return null; + + List entries = new List(); + foreach(DataRow dataRow in dataSet.Tables[0].Rows) + { + if(!int.TryParse(dataRow["extension_id"].ToString(), out int extensionId)) continue; + if(extensionId == 0) continue; + + entries.Add(GetInstructionSetExtension(extensionId)); + } + + return entries; + } + catch(Exception ex) + { + Console.WriteLine("Error getting instruction set extension."); + Console.WriteLine(ex); + return null; + } + } + + /// + /// Counts the number of instruction set extensions in the database + /// + /// Entries in database + public long CountInstructionSetExtensions() + { + #if DEBUG + Console.WriteLine("Counting instruction_set_extensions..."); + #endif + + IDbCommand dbcmd = dbCon.CreateCommand(); + dbcmd.CommandText = "SELECT COUNT(*) FROM instruction_set_extensions"; + object count = dbcmd.ExecuteScalar(); + dbcmd.Dispose(); + try { return Convert.ToInt64(count); } + catch { return 0; } + } + + /// + /// Adds a new instruction set extension to the database + /// + /// Entry to add + /// ID of added entry + /// true if added correctly, false otherwise + public bool AddInstructionSetExtension(InstructionSetExtension entry, out long id) + { + #if DEBUG + Console.Write("Adding instruction set extension `{0}`...", entry.Name); + #endif + + IDbCommand dbcmd = GetCommandInstructionSetExtension(entry); + IDbTransaction trans = dbCon.BeginTransaction(); + dbcmd.Transaction = trans; + + const string SQL = "INSERT INTO instruction_set_extensions (extension) VALUES (@extension)"; + + dbcmd.CommandText = SQL; + + dbcmd.ExecuteNonQuery(); + trans.Commit(); + dbcmd.Dispose(); + + id = dbCore.LastInsertRowId; + + #if DEBUG + Console.WriteLine(" id {0}", id); + #endif + + return true; + } + + /// + /// Updated a instruction set extension in the database + /// + /// Updated entry + /// true if updated correctly, false otherwise + public bool UpdateInstructionSetExtension(InstructionSetExtension entry) + { + #if DEBUG + Console.WriteLine("Updating instruction set extension `{0}`...", entry.Name); + #endif + + IDbCommand dbcmd = GetCommandInstructionSetExtension(entry); + IDbTransaction trans = dbCon.BeginTransaction(); + dbcmd.Transaction = trans; + + string sql = "UPDATE instruction_set_extensions SET extension = @extension " + $"WHERE id = {entry.Id}"; + + dbcmd.CommandText = sql; + + dbcmd.ExecuteNonQuery(); + trans.Commit(); + dbcmd.Dispose(); + + return true; + } + + /// + /// Removes a instruction set extension from the database + /// + /// ID of entry to remove + /// true if removed correctly, false otherwise + public bool RemoveInstructionSetExtension(long id) + { + #if DEBUG + Console.WriteLine("Removing instruction set extension widh id `{0}`...", id); + #endif + + IDbCommand dbcmd = dbCon.CreateCommand(); + IDbTransaction trans = dbCon.BeginTransaction(); + dbcmd.Transaction = trans; + + string sql = $"DELETE FROM instruction_set_extensions WHERE id = '{id}';"; + + dbcmd.CommandText = sql; + + dbcmd.ExecuteNonQuery(); + trans.Commit(); + dbcmd.Dispose(); + + return true; + } + + IDbCommand GetCommandInstructionSetExtension(InstructionSetExtension entry) + { + IDbCommand dbcmd = dbCon.CreateCommand(); + + IDbDataParameter param1 = dbcmd.CreateParameter(); + + param1.ParameterName = "@extension"; + + param1.DbType = DbType.String; + + param1.Value = entry.Name; + + dbcmd.Parameters.Add(param1); + + return dbcmd; + } + + static List InstructionSetExtensionsFromDataTable(DataTable dataTable) + { + List entries = new List(); + + foreach(DataRow dataRow in dataTable.Rows) + { + InstructionSetExtension entry = new InstructionSetExtension + { + Id = int.Parse(dataRow["id"].ToString()), + Name = dataRow["extension"].ToString() + }; + + entries.Add(entry); + } + + return entries; + } + } +} \ No newline at end of file diff --git a/Cicm.Database/Operations/Operations.cs b/Cicm.Database/Operations/Operations.cs index baaabf42..294aa690 100644 --- a/Cicm.Database/Operations/Operations.cs +++ b/Cicm.Database/Operations/Operations.cs @@ -35,7 +35,7 @@ namespace Cicm.Database public partial class Operations { /// Last known database version - const int DB_VERSION = 9; + const int DB_VERSION = 10; readonly IDbConnection dbCon; readonly IDbCore dbCore; diff --git a/Cicm.Database/Operations/Processor.cs b/Cicm.Database/Operations/Processor.cs index 73838c82..3fd2bc6c 100644 --- a/Cicm.Database/Operations/Processor.cs +++ b/Cicm.Database/Operations/Processor.cs @@ -210,7 +210,15 @@ namespace Cicm.Database IDbTransaction trans = dbCon.BeginTransaction(); dbcmd.Transaction = trans; - string sql = "UPDATE processors SET name = @name " + $"WHERE id = {entry.Id}"; + string sql = "UPDATE processors SET name = @name, company = @company, model_code = @model_code," + + "introduced = @introduced, instruction_set = @instruction_set, speed = @speed, " + + "package = @package, GPRs = @GPRs, GPR_size = @GPR_size, FPRs = @FPRs, FPR_size = @FPR_size," + + "cores = @cores, threads_per_core = @threads_per_core, process = @process," + + "process_nm = @process_nm, die_size = @die_size, transistors = @transistors," + + "data_bus = @data_bus, addr_bus = @addr_bus, SIMD_registers = @SIMD_registers," + + "SIMD_size = @SIMD_size, L1_instruction = @L1_instruction, L1_data = @L1_data, L2 = @L2," + + "L3 = @L3 " + + $"WHERE id = {entry.Id}"; dbcmd.CommandText = sql; @@ -251,20 +259,116 @@ namespace Cicm.Database { IDbCommand dbcmd = dbCon.CreateCommand(); - IDbDataParameter param1 = dbcmd.CreateParameter(); + IDbDataParameter param1 = dbcmd.CreateParameter(); + IDbDataParameter param2 = dbcmd.CreateParameter(); + IDbDataParameter param3 = dbcmd.CreateParameter(); + IDbDataParameter param4 = dbcmd.CreateParameter(); + IDbDataParameter param5 = dbcmd.CreateParameter(); + IDbDataParameter param6 = dbcmd.CreateParameter(); + IDbDataParameter param7 = dbcmd.CreateParameter(); + IDbDataParameter param8 = dbcmd.CreateParameter(); + IDbDataParameter param9 = dbcmd.CreateParameter(); + IDbDataParameter param10 = dbcmd.CreateParameter(); + IDbDataParameter param11 = dbcmd.CreateParameter(); + IDbDataParameter param12 = dbcmd.CreateParameter(); + IDbDataParameter param13 = dbcmd.CreateParameter(); + IDbDataParameter param14 = dbcmd.CreateParameter(); + IDbDataParameter param15 = dbcmd.CreateParameter(); + IDbDataParameter param16 = dbcmd.CreateParameter(); + IDbDataParameter param17 = dbcmd.CreateParameter(); + IDbDataParameter param18 = dbcmd.CreateParameter(); + IDbDataParameter param19 = dbcmd.CreateParameter(); + IDbDataParameter param20 = dbcmd.CreateParameter(); + IDbDataParameter param21 = dbcmd.CreateParameter(); + IDbDataParameter param22 = dbcmd.CreateParameter(); + IDbDataParameter param23 = dbcmd.CreateParameter(); + IDbDataParameter param24 = dbcmd.CreateParameter(); + IDbDataParameter param25 = dbcmd.CreateParameter(); - param1.ParameterName = "@name"; + param1.ParameterName = "@name"; + param2.ParameterName = "@company"; + param3.ParameterName = "@model_code"; + param4.ParameterName = "@introduced"; + param5.ParameterName = "@instruction_set"; + param6.ParameterName = "@speed"; + param7.ParameterName = "@package"; + param8.ParameterName = "@GPRs"; + param9.ParameterName = "@GPR_size"; + param10.ParameterName = "@FPRs"; + param11.ParameterName = "@FPR_size"; + param12.ParameterName = "@cores"; + param13.ParameterName = "@threads_per_core"; + param14.ParameterName = "@process"; + param15.ParameterName = "@process_nm"; + param16.ParameterName = "@die_size"; + param17.ParameterName = "@transistors"; + param18.ParameterName = "@addr_bus"; + param19.ParameterName = "@data_bus"; + param20.ParameterName = "@SIMD_registers"; + param21.ParameterName = "@SIMD_size"; + param22.ParameterName = "@L1_instruction"; + param23.ParameterName = "@L1_data"; + param24.ParameterName = "@L2"; + param25.ParameterName = "@L3"; - param1.DbType = DbType.String; + param1.DbType = DbType.String; + param2.DbType = DbType.Int32; + param3.DbType = DbType.String; + param4.DbType = DbType.DateTime; + param5.DbType = DbType.Int32; + param6.DbType = DbType.Double; + param7.DbType = DbType.String; + param8.DbType = DbType.Int32; + param9.DbType = DbType.Int32; + param10.DbType = DbType.Int32; + param11.DbType = DbType.Int32; + param12.DbType = DbType.Int32; + param13.DbType = DbType.Int32; + param14.DbType = DbType.String; + param15.DbType = DbType.Double; + param16.DbType = DbType.Double; + param17.DbType = DbType.UInt64; + param18.DbType = DbType.Int32; + param19.DbType = DbType.Int32; + param20.DbType = DbType.Int32; + param21.DbType = DbType.Int32; + param22.DbType = DbType.Double; + param23.DbType = DbType.Double; + param24.DbType = DbType.Double; + param25.DbType = DbType.Double; - param1.Value = entry.Name; + param1.Value = entry.Name; + param2.Value = entry.Company == null ? null : (object)entry.Company.Id; + param3.Value = entry.ModelCode; + param4.Value = entry.Introduced == DateTime.MinValue ? null : (object)entry.Introduced; + param5.Value = entry.InstructionSet?.Name; + param6.Value = entry.Speed; + param7.Value = entry.Package; + param8.Value = entry.Gpr; + param9.Value = entry.GprSize; + param10.Value = entry.Fpr; + param11.Value = entry.FprSize; + param12.Value = entry.Cores; + param13.Value = entry.ThreadsPerCore; + param14.Value = entry.Process; + param15.Value = entry.ProcessNm; + param16.Value = entry.DieSize; + param17.Value = entry.Transistors; + param18.Value = entry.AddressBus; + param19.Value = entry.DataBus; + param20.Value = entry.Simd; + param21.Value = entry.SimdSize; + param22.Value = entry.L1Instruction; + param23.Value = entry.L1Data; + param24.Value = entry.L2; + param25.Value = entry.L3; dbcmd.Parameters.Add(param1); return dbcmd; } - static List ProcessorsFromDataTable(DataTable dataTable) + List ProcessorsFromDataTable(DataTable dataTable) { List entries = new List(); @@ -272,10 +376,40 @@ namespace Cicm.Database { Processor entry = new Processor { - Id = int.Parse(dataRow["id"].ToString()), - Name = dataRow["name"].ToString() + Id = int.Parse(dataRow["id"].ToString()), + Name = dataRow["name"].ToString(), + ModelCode = dataRow["model_code"].ToString(), + Speed = Convert.ToDouble(dataRow["speed"].ToString()), + Package = dataRow["package"].ToString(), + Gpr = Convert.ToInt32(dataRow["GPRs"].ToString()), + GprSize = Convert.ToInt32(dataRow["GPR_size"].ToString()), + Fpr = Convert.ToInt32(dataRow["FPRs"].ToString()), + FprSize = Convert.ToInt32(dataRow["FPR_size"].ToString()), + Cores = Convert.ToInt32(dataRow["cores"].ToString()), + ThreadsPerCore = Convert.ToInt32(dataRow["threads_per_core"].ToString()), + Process = dataRow["process"].ToString(), + ProcessNm = Convert.ToSingle(dataRow["process_nm"].ToString()), + DieSize = Convert.ToSingle(dataRow["die_size"].ToString()), + Transistors = Convert.ToUInt64(dataRow["transistors"].ToString()), + AddressBus = Convert.ToInt32(dataRow["addr_bus"].ToString()), + DataBus = Convert.ToInt32(dataRow["data_bus"].ToString()), + Simd = Convert.ToInt32(dataRow["SIMD_registers"].ToString()), + SimdSize = Convert.ToInt32(dataRow["SIMD_size"].ToString()), + L1Instruction = Convert.ToSingle(dataRow["L1_instruction"].ToString()), + L1Data = Convert.ToSingle(dataRow["L1_data"].ToString()), + L2 = Convert.ToSingle(dataRow["L2"].ToString()), + L3 = Convert.ToSingle(dataRow["L3"].ToString()) }; + if(!string.IsNullOrEmpty(dataRow["company"].ToString())) + entry.Company = GetCompany(Convert.ToInt32(dataRow["company"].ToString())); + + if(!string.IsNullOrEmpty(dataRow["introduced"].ToString())) + entry.Introduced = Convert.ToDateTime(dataRow["introduced"].ToString()); + + if(!string.IsNullOrEmpty(dataRow["instruction_set"].ToString())) + entry.InstructionSet = GetInstructionSet(Convert.ToInt32(dataRow["instruction_set"].ToString())); + entries.Add(entry); } diff --git a/Cicm.Database/Operations/Update.cs b/Cicm.Database/Operations/Update.cs index 0b96cbf7..c096f524 100644 --- a/Cicm.Database/Operations/Update.cs +++ b/Cicm.Database/Operations/Update.cs @@ -113,6 +113,11 @@ namespace Cicm.Database UpdateDatabaseToV9(); break; } + case 9: + { + UpdateDatabaseToV10(); + break; + } } OptimizeDatabase(); @@ -829,6 +834,120 @@ namespace Cicm.Database dbCmd.Dispose(); } + void UpdateDatabaseToV10() + { + Console.WriteLine("Updating database to version 10"); + + Console.WriteLine("Creating table `instruction_sets`"); + IDbCommand dbCmd = dbCon.CreateCommand(); + IDbTransaction trans = dbCon.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = V10.InstructionSets; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Creating table `instruction_set_extensions`"); + dbCmd = dbCon.CreateCommand(); + trans = dbCon.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = V10.InstructionSetExtensions; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Creating table `instruction_set_extensions_by_processor`"); + dbCmd = dbCon.CreateCommand(); + trans = dbCon.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = V10.InstructionSetExtensionsByProcessor; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Adding new columns to table `processors`"); + dbCmd = dbCon.CreateCommand(); + trans = dbCon.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = "ALTER TABLE `processors` ADD COLUMN `company` INT NULL;\n" + + "ALTER TABLE `processors` ADD COLUMN `model_code` VARCHAR(45) NULL;\n" + + "ALTER TABLE `processors` ADD COLUMN `introduced` DATETIME NULL;\n" + + "ALTER TABLE `processors` ADD COLUMN `instruction_set` INT NULL;\n" + + "ALTER TABLE `processors` ADD COLUMN `speed` DOUBLE NULL;\n" + + "ALTER TABLE `processors` ADD COLUMN `package` VARCHAR(45) NULL;\n" + + "ALTER TABLE `processors` ADD COLUMN `GPRs` INT NULL;\n" + + "ALTER TABLE `processors` ADD COLUMN `GPR_size` INT NULL;\n" + + "ALTER TABLE `processors` ADD COLUMN `FPRs` INT NULL;\n" + + "ALTER TABLE `processors` ADD COLUMN `FPR_size` INT NULL;\n" + + "ALTER TABLE `processors` ADD COLUMN `cores` INT NULL;\n" + + "ALTER TABLE `processors` ADD COLUMN `threads_per_core` INT NULL;\n" + + "ALTER TABLE `processors` ADD COLUMN `process` VARCHAR(45) NULL;\n" + + "ALTER TABLE `processors` ADD COLUMN `process_nm` FLOAT NULL;\n" + + "ALTER TABLE `processors` ADD COLUMN `die_size` FLOAT NULL;\n" + + "ALTER TABLE `processors` ADD COLUMN `transistors` BIGINT NULL;\n" + + "ALTER TABLE `processors` ADD COLUMN `data_bus` INT NULL;\n" + + "ALTER TABLE `processors` ADD COLUMN `addr_bus` INT NULL;\n" + + "ALTER TABLE `processors` ADD COLUMN `SIMD_registers` INT NULL;\n" + + "ALTER TABLE `processors` ADD COLUMN `SIMD_size` INT NULL;\n" + + "ALTER TABLE `processors` ADD COLUMN `L1_instruction` FLOAT NULL;\n" + + "ALTER TABLE `processors` ADD COLUMN `L1_data` FLOAT NULL;\n" + + "ALTER TABLE `processors` ADD COLUMN `L2` FLOAT NULL;\n" + + "ALTER TABLE `processors` ADD COLUMN `L3` FLOAT NULL;"; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Adding new indexes to table `processors`"); + dbCmd = dbCon.CreateCommand(); + trans = dbCon.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = + "CREATE INDEX `idx_processors_company` ON `processors` (`company`);\n" + + "CREATE INDEX `idx_processors_model_code` ON `processors` (`model_code`);\n" + + "CREATE INDEX `idx_processors_introduced` ON `processors` (`introduced`);\n" + + "CREATE INDEX `idx_processors_instruction_set` ON `processors` (`instruction_set`);\n" + + "CREATE INDEX `idx_processors_speed` ON `processors` (`speed`);\n" + + "CREATE INDEX `idx_processors_package` ON `processors` (`package`);\n" + + "CREATE INDEX `idx_processors_GPRs` ON `processors` (`GPRs`);\n" + + "CREATE INDEX `idx_processors_GPR_size` ON `processors` (`GPR_size`);\n" + + "CREATE INDEX `idx_processors_FPRs` ON `processors` (`FPRs`);\n" + + "CREATE INDEX `idx_processors_FPR_size` ON `processors` (`FPR_size`);\n" + + "CREATE INDEX `idx_processors_cores` ON `processors` (`cores`);\n" + + "CREATE INDEX `idx_processors_threads_per_core` ON `processors` (`threads_per_core`);\n" + + "CREATE INDEX `idx_processors_process` ON `processors` (`process`);\n" + + "CREATE INDEX `idx_processors_process_nm` ON `processors` (`process_nm`);\n" + + "CREATE INDEX `idx_processors_die_size` ON `processors` (`die_size`);\n" + + "CREATE INDEX `idx_processors_transistors` ON `processors` (`transistors`);\n" + + "CREATE INDEX `idx_processors_data_bus` ON `processors` (`data_bus`);\n" + + "CREATE INDEX `idx_processors_addr_bus` ON `processors` (`addr_bus`);\n" + + "CREATE INDEX `idx_processors_SIMD_registers` ON `processors` (`SIMD_registers`);\n" + + "CREATE INDEX `idx_processors_SIMD_size` ON `processors` (`SIMD_size`);\n" + + "CREATE INDEX `idx_processors_L1_instruction` ON `processors` (`L1_instruction`);\n" + + "CREATE INDEX `idx_processors_L1_data` ON `processors` (`L1_data`);\n" + + "CREATE INDEX `idx_processors_L2` ON `processors` (`L2`);\n" + + "CREATE INDEX `idx_processors_L3` ON `processors` (`L3`);"; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Adding new foreign keys to table `processors`"); + dbCmd = dbCon.CreateCommand(); + trans = dbCon.BeginTransaction(); + dbCmd.Transaction = trans; + dbCmd.CommandText = + "ALTER TABLE `processors` ADD FOREIGN KEY `fk_processors_company` (company) REFERENCES `companies` (`id`) ON UPDATE CASCADE;\n" + + "ALTER TABLE `processors` ADD FOREIGN KEY `fk_processors_instruction_set` (instruction_set) REFERENCES `instruction_sets` (`id`) ON UPDATE CASCADE;"; + dbCmd.ExecuteNonQuery(); + trans.Commit(); + dbCmd.Dispose(); + + Console.WriteLine("Setting new database version to 10..."); + dbCmd = dbCon.CreateCommand(); + dbCmd.CommandText = "INSERT INTO cicm_db (version) VALUES ('10')"; + dbCmd.ExecuteNonQuery(); + dbCmd.Dispose(); + } + void OptimizeDatabase() { IDbCommand dbCmd = dbCon.CreateCommand(); diff --git a/Cicm.Database/Schemas/InstructionSet.cs b/Cicm.Database/Schemas/InstructionSet.cs new file mode 100644 index 00000000..0918665d --- /dev/null +++ b/Cicm.Database/Schemas/InstructionSet.cs @@ -0,0 +1,40 @@ +/****************************************************************************** +// Canary Islands Computer Museum Website +// ---------------------------------------------------------------------------- +// +// Filename : InstructionSet.cs +// Author(s) : Natalia Portillo +// +// --[ Description ] ---------------------------------------------------------- +// +// High level representation of an instruction set. +// +// --[ License ] -------------------------------------------------------------- +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// ---------------------------------------------------------------------------- +// Copyright © 2003-2018 Natalia Portillo +*******************************************************************************/ + +namespace Cicm.Database.Schemas +{ + public class InstructionSet + { + /// Instruction Set ID + public int Id; + /// Name of the instruction set + public string Name; + } +} \ No newline at end of file diff --git a/Cicm.Database/Schemas/InstructionSetExtension.cs b/Cicm.Database/Schemas/InstructionSetExtension.cs new file mode 100644 index 00000000..b45a9d67 --- /dev/null +++ b/Cicm.Database/Schemas/InstructionSetExtension.cs @@ -0,0 +1,40 @@ +/****************************************************************************** +// Canary Islands Computer Museum Website +// ---------------------------------------------------------------------------- +// +// Filename : InstructionSet.cs +// Author(s) : Natalia Portillo +// +// --[ Description ] ---------------------------------------------------------- +// +// High level representation of an instruction set. +// +// --[ License ] -------------------------------------------------------------- +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// ---------------------------------------------------------------------------- +// Copyright © 2003-2018 Natalia Portillo +*******************************************************************************/ + +namespace Cicm.Database.Schemas +{ + public class InstructionSetExtension + { + /// Instruction set extension ID + public int Id; + /// Instruction set extension name + public string Name; + } +} \ No newline at end of file diff --git a/Cicm.Database/Schemas/Processor.cs b/Cicm.Database/Schemas/Processor.cs index e9314527..bbe76555 100644 --- a/Cicm.Database/Schemas/Processor.cs +++ b/Cicm.Database/Schemas/Processor.cs @@ -28,14 +28,69 @@ // Copyright © 2003-2018 Natalia Portillo *******************************************************************************/ +using System; + namespace Cicm.Database.Schemas { /// Processor public class Processor { + /// Size in bits of address bus with host (not interprocessor) + public int AddressBus; + /// Company + public Company Company; + /// How many processor cores per processor package + public int Cores; + /// Size in bits of data bus with host (not interprocessor) + public int DataBus; + /// Size of die in square milimeters + public float DieSize; + /// Number of available Floating Point Registers + public int Fpr; + /// Size in bits of FPRs + public int FprSize; + /// Number of available General Purpose Registers + public int Gpr; + /// Size in bits of GPRs + public int GprSize; /// ID public int Id; + /// Instruction set + public InstructionSet InstructionSet; + /// Extensions to the instruction set that are implemented in this processor + public InstructionSetExtension[] InstructionSetExtensions; + /// Datetime of introduction + public DateTime Introduced; + /// Size in kibibytes of L1 data cache. If 0, is size of L1 unified cache + public float L1Data; + /// Size in kibibytes of L1 instruction cache. If is 0, this is size of L1 unified cache + public float L1Instruction; + /// + /// Size in kibibytes of L2 cache. It includes cache that's in same physical package but not in same chip die + /// (e.g. Pentium II) + /// + public float L2; + /// Size in kibibytes of L3 cache + public float L3; + /// Model/SKU code + public string ModelCode; /// Name public string Name; + /// Package + public string Package; + /// Name of litography process + public string Process; + /// Nanometers of litography process + public float ProcessNm; + /// Number of available SIMD registers + public int Simd; + /// Size in bits of SIMD registers + public int SimdSize; + /// Nominal speed, in MHz + public double Speed; + /// How many simultaneos threads can run on each processor core + public int ThreadsPerCore; + /// How many transistors in package + public ulong Transistors; } } \ No newline at end of file diff --git a/Cicm.Database/Schemas/Sql/V10.cs b/Cicm.Database/Schemas/Sql/V10.cs new file mode 100644 index 00000000..455d623b --- /dev/null +++ b/Cicm.Database/Schemas/Sql/V10.cs @@ -0,0 +1,168 @@ +/****************************************************************************** +// Canary Islands Computer Museum Website +// ---------------------------------------------------------------------------- +// +// Filename : V9.cs +// Author(s) : Natalia Portillo +// +// --[ Description ] ---------------------------------------------------------- +// +// Contains SQL queries to create the database version 7. +// +// --[ License ] -------------------------------------------------------------- +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// ---------------------------------------------------------------------------- +// Copyright © 2003-2018 Natalia Portillo +*******************************************************************************/ + +namespace Cicm.Database.Schemas.Sql +{ + public static class V10 + { + public static readonly string Admins = V9.Admins; + + public static readonly string BrowserTests = V9.BrowserTests; + + public static readonly string CicmDb = "CREATE TABLE `cicm_db` (\n" + + "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + + "`version` int(11) NOT NULL,\n" + + "`updated` datetime DEFAULT CURRENT_TIMESTAMP,\n" + + "PRIMARY KEY (`id`)\n" + ");\n" + + "INSERT INTO cicm_db (version) VALUES ('10');"; + + public static readonly string Companies = V9.Companies; + + public static readonly string Computers = V9.Computers; + + public static readonly string Consoles = V9.Consoles; + + public static readonly string DiskFormats = V9.DiskFormats; + + public static readonly string Forbidden = V9.Forbidden; + + public static readonly string Gpus = V9.Gpus; + + public static readonly string Logs = V9.Logs; + + public static readonly string MoneyDonations = V9.MoneyDonations; + + public static readonly string MusicSynths = V9.MusicSynths; + + public static readonly string News = V9.News; + + public static readonly string OwnedComputers = V9.OwnedComputers; + + public static readonly string OwnedConsoles = V9.OwnedConsoles; + + public static readonly string Processors = + "CREATE TABLE `processors` (\n" + + "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + + "`name` char(50) NOT NULL DEFAULT '',\n" + + "`company` int(11) DEFAULT NULL,\n" + + "`model_code` varchar(45) DEFAULT NULL,\n" + + "`introduced` datetime DEFAULT NULL,\n" + + "`instruction_set` int(11) DEFAULT NULL,\n" + + "`speed` double DEFAULT NULL,\n" + + "`package` varchar(45) DEFAULT NULL,\n" + + "`GPRs` int(11) DEFAULT NULL,\n" + + "`GPR_size` int(11) DEFAULT NULL,\n" + + "`FPRs` int(11) DEFAULT NULL,\n" + + "`FPR_size` int(11) DEFAULT NULL,\n" + + "`cores` int(11) DEFAULT NULL,\n" + + "`threads_per_core` int(11) DEFAULT NULL,\n" + + "`process` varchar(45) DEFAULT NULL,\n" + + "`process_nm` float DEFAULT NULL,\n" + + "`die_size` float DEFAULT NULL,\n" + + "`transistors` bigint(20) DEFAULT NULL,\n" + + "`data_bus` int(11) DEFAULT NULL,\n" + + "`addr_bus` int(11) DEFAULT NULL,\n" + + "`SIMD_registers` int(11) DEFAULT NULL,\n" + + "`SIMD_size` int(11) DEFAULT NULL,\n" + + "`L1_instruction` float DEFAULT NULL,\n" + + "`L1_data` float DEFAULT NULL,\n" + + "`L2` float DEFAULT NULL,\n" + + "`L3` float DEFAULT NULL,\n" + + "PRIMARY KEY (`id`),\n" + + "KEY `idx_processors_name` (`name`),\n" + + "KEY `idx_processors_company` (`company`),\n" + + "KEY `idx_processors_model_code` (`model_code`),\n" + + "KEY `idx_processors_introduced` (`introduced`),\n" + + "KEY `idx_processors_instruction_set` (`instruction_set`),\n" + + "KEY `idx_processors_speed` (`speed`),\n" + + "KEY `idx_processors_package` (`package`),\n" + + "KEY `idx_processors_GPRs` (`GPRs`),\n" + + "KEY `idx_processors_GPR_size` (`GPR_size`),\n" + + "KEY `idx_processors_FPRs` (`FPRs`),\n" + + "KEY `idx_processors_FPR_size` (`FPR_size`),\n" + + "KEY `idx_processors_cores` (`cores`),\n" + + "KEY `idx_processors_threads_per_core` (`threads_per_core`),\n" + + "KEY `idx_processors_process` (`process`),\n" + + "KEY `idx_processors_process_nm` (`process_nm`),\n" + + "KEY `idx_processors_die_size` (`die_size`),\n" + + "KEY `idx_processors_transistors` (`transistors`),\n" + + "KEY `idx_processors_data_bus` (`data_bus`),\n" + + "KEY `idx_processors_addr_bus` (`addr_bus`),\n" + + "KEY `idx_processors_SIMD_registers` (`SIMD_registers`),\n" + + "KEY `idx_processors_SIMD_size` (`SIMD_size`),\n" + + "KEY `idx_processors_L1_instruction` (`L1_instruction`),\n" + + "KEY `idx_processors_L1_data` (`L1_data`),\n" + + "KEY `idx_processors_L2` (`L2`),\n" + + "KEY `idx_processors_L3` (`L3`),\n" + + "CONSTRAINT `fk_processors_company` FOREIGN KEY (`company`) REFERENCES `companies` (`id`) ON UPDATE CASCADE,\n" + + "CONSTRAINT `fk_processors_instruction_set` FOREIGN KEY (`instruction_set`) REFERENCES `instruction_sets` (`id`) ON UPDATE CASCADE);"; + + public static readonly string SoundSynths = V9.SoundSynths; + + public static readonly string ComputersForeignKeys = V9.ComputersForeignKeys; + + public static readonly string ConsolesForeignKeys = V9.ConsolesForeignKeys; + + public static readonly string Iso3166Numeric = V9.Iso3166Numeric; + + public static readonly string Iso3166NumericValues = V9.Iso3166NumericValues; + + public static readonly string CompaniesForeignKeys = V9.CompaniesForeignKeys; + + public static readonly string CompanyLogos = V9.CompanyLogos; + + public static readonly string CompanyDescriptions = V9.CompanyDescriptions; + + public static readonly string InstructionSets = "CREATE TABLE IF NOT EXISTS `instruction_sets` (\n" + + "`id` INT NOT NULL AUTO_INCREMENT,\n" + + "`instruction_set` VARCHAR(45) NOT NULL,\n" + + "PRIMARY KEY (`id`));"; + + public static readonly string InstructionSetExtensions = + "CREATE TABLE IF NOT EXISTS `instruction_set_extensions` (\n" + "`id` INT NOT NULL AUTO_INCREMENT,\n" + + "`extension` VARCHAR(45) NOT NULL,\n" + "PRIMARY KEY (`id`));"; + + public static readonly string InstructionSetExtensionsByProcessor = + "CREATE TABLE IF NOT EXISTS `instruction_set_extensions_by_processor` (\n" + + "`id` INT NOT NULL AUTO_INCREMENT,\n" + + "`processor_id` INT NOT NULL,\n" + + "`extension_id` INT NOT NULL,\n" + + "PRIMARY KEY (`id`, `processor_id`, `extension_id`),\n" + + "INDEX `idx_setextension_processor` (`processor_id` ASC),\n" + + "INDEX `idx_setextension_extension` (`extension_id` ASC),\n" + + "CONSTRAINT `fk_extension_processor_id`\n" + + "FOREIGN KEY (`processor_id`)\n" + + "REFERENCES `processors` (`id`)\n" + "ON DELETE RESTRICT\n" + + "ON UPDATE CASCADE,\n" + + "CONSTRAINT `fk_extension_extension_id`\n" + "FOREIGN KEY (`extension_id`)\n" + + "REFERENCES `instruction_set_extensions` (`id`)\n" + + "ON DELETE RESTRICT\n" + "ON UPDATE CASCADE);"; + } +} \ No newline at end of file diff --git a/cicm_web/cicm_web.csproj b/cicm_web/cicm_web.csproj index 28918555..cee262f4 100644 --- a/cicm_web/cicm_web.csproj +++ b/cicm_web/cicm_web.csproj @@ -2,7 +2,7 @@ netcoreapp2.0 - 3.0.99.156 + 3.0.99.158 Canary Islands Computer Museum Copyright © 2003-2018 Natalia Portillo Canary Islands Computer Museum Website