diff --git a/01-Arbeitsjournal_Datenbanken.docx b/01-Arbeitsjournal_Datenbanken.docx new file mode 100644 index 0000000..691bb79 Binary files /dev/null and b/01-Arbeitsjournal_Datenbanken.docx differ diff --git a/02-Semesterarbeit_Datenbanken.docx b/02-Semesterarbeit_Datenbanken.docx new file mode 100644 index 0000000..2385808 Binary files /dev/null and b/02-Semesterarbeit_Datenbanken.docx differ diff --git a/MonitoringClient/MonitoringClient.exe b/MonitoringClient/MonitoringClient.exe new file mode 100644 index 0000000..347441a Binary files /dev/null and b/MonitoringClient/MonitoringClient.exe differ diff --git a/MonitoringClient/MySql.Data.dll b/MonitoringClient/MySql.Data.dll new file mode 100644 index 0000000..0c7b2bb Binary files /dev/null and b/MonitoringClient/MySql.Data.dll differ diff --git a/MonitoringClient/Source/MonitoringClient.sln b/MonitoringClient/Source/MonitoringClient.sln new file mode 100644 index 0000000..6db1c79 --- /dev/null +++ b/MonitoringClient/Source/MonitoringClient.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.31101.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonitoringClient", "MonitoringClient\MonitoringClient.csproj", "{ED6D9A70-6FBD-44A8-AA32-EAC5892C84B6}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {ED6D9A70-6FBD-44A8-AA32-EAC5892C84B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {ED6D9A70-6FBD-44A8-AA32-EAC5892C84B6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {ED6D9A70-6FBD-44A8-AA32-EAC5892C84B6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {ED6D9A70-6FBD-44A8-AA32-EAC5892C84B6}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/MonitoringClient/Source/MonitoringClient/Form1.Designer.cs b/MonitoringClient/Source/MonitoringClient/Form1.Designer.cs new file mode 100644 index 0000000..4e9435f --- /dev/null +++ b/MonitoringClient/Source/MonitoringClient/Form1.Designer.cs @@ -0,0 +1,181 @@ +namespace MonitoringClient { + partial class Form1 { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) { + if (disposing && (components != null)) { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() { + this.txtConnectionString = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.btnLogClear = new System.Windows.Forms.Button(); + this.btnLoadData = new System.Windows.Forms.Button(); + this.lsvLogEntries = new System.Windows.Forms.ListView(); + this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader3 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader6 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader7 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.SuspendLayout(); + // + // txtConnectionString + // + this.txtConnectionString.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.txtConnectionString.Location = new System.Drawing.Point(131, 6); + this.txtConnectionString.Name = "txtConnectionString"; + this.txtConnectionString.Size = new System.Drawing.Size(429, 20); + this.txtConnectionString.TabIndex = 0; + this.txtConnectionString.Text = "Server=localhost;Database=inventory;Uid=root;Pwd=;"; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(12, 9); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(113, 13); + this.label1.TabIndex = 1; + this.label1.Text = "Datenbankverbindung"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(12, 43); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(117, 13); + this.label2.TabIndex = 3; + this.label2.Text = "Unquitierte Logeinträge"; + // + // btnLogClear + // + this.btnLogClear.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.btnLogClear.Location = new System.Drawing.Point(13, 226); + this.btnLogClear.Name = "btnLogClear"; + this.btnLogClear.Size = new System.Drawing.Size(547, 23); + this.btnLogClear.TabIndex = 4; + this.btnLogClear.Text = "markierte Einträge quittieren"; + this.btnLogClear.UseVisualStyleBackColor = true; + this.btnLogClear.Click += new System.EventHandler(this.btnLogClear_Click); + // + // btnLoadData + // + this.btnLoadData.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.btnLoadData.Location = new System.Drawing.Point(131, 38); + this.btnLoadData.Name = "btnLoadData"; + this.btnLoadData.Size = new System.Drawing.Size(429, 23); + this.btnLoadData.TabIndex = 5; + this.btnLoadData.Text = "Daten laden"; + this.btnLoadData.UseVisualStyleBackColor = true; + this.btnLoadData.Click += new System.EventHandler(this.btnLoadData_Click); + // + // lsvLogEntries + // + this.lsvLogEntries.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.lsvLogEntries.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeader1, + this.columnHeader2, + this.columnHeader3, + this.columnHeader4, + this.columnHeader5, + this.columnHeader6, + this.columnHeader7}); + this.lsvLogEntries.FullRowSelect = true; + this.lsvLogEntries.GridLines = true; + this.lsvLogEntries.HideSelection = false; + this.lsvLogEntries.Location = new System.Drawing.Point(15, 67); + this.lsvLogEntries.Name = "lsvLogEntries"; + this.lsvLogEntries.Size = new System.Drawing.Size(545, 153); + this.lsvLogEntries.TabIndex = 6; + this.lsvLogEntries.UseCompatibleStateImageBehavior = false; + this.lsvLogEntries.View = System.Windows.Forms.View.Details; + // + // columnHeader1 + // + this.columnHeader1.Text = "Id"; + // + // columnHeader2 + // + this.columnHeader2.Text = "POD"; + // + // columnHeader3 + // + this.columnHeader3.Text = "Location"; + // + // columnHeader4 + // + this.columnHeader4.Text = "Hostname"; + // + // columnHeader5 + // + this.columnHeader5.Text = "Severity"; + // + // columnHeader6 + // + this.columnHeader6.Text = "Timestamp"; + // + // columnHeader7 + // + this.columnHeader7.Text = "Message"; + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(572, 261); + this.Controls.Add(this.lsvLogEntries); + this.Controls.Add(this.btnLoadData); + this.Controls.Add(this.btnLogClear); + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.Controls.Add(this.txtConnectionString); + this.Name = "Form1"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Monitoring"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TextBox txtConnectionString; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Button btnLogClear; + private System.Windows.Forms.Button btnLoadData; + private System.Windows.Forms.ListView lsvLogEntries; + private System.Windows.Forms.ColumnHeader columnHeader1; + private System.Windows.Forms.ColumnHeader columnHeader2; + private System.Windows.Forms.ColumnHeader columnHeader3; + private System.Windows.Forms.ColumnHeader columnHeader4; + private System.Windows.Forms.ColumnHeader columnHeader5; + private System.Windows.Forms.ColumnHeader columnHeader6; + private System.Windows.Forms.ColumnHeader columnHeader7; + } +} + diff --git a/MonitoringClient/Source/MonitoringClient/Form1.cs b/MonitoringClient/Source/MonitoringClient/Form1.cs new file mode 100644 index 0000000..ba28674 --- /dev/null +++ b/MonitoringClient/Source/MonitoringClient/Form1.cs @@ -0,0 +1,67 @@ +using System; +using System.Data; +using System.Windows.Forms; +using MonitoringClient.Properties; +using MySql.Data.MySqlClient; + +namespace MonitoringClient { + public partial class Form1 : Form { + public Form1() { + InitializeComponent(); + if (!string.IsNullOrWhiteSpace(Settings.Default.ConnectionString)) { + this.txtConnectionString.Text = Settings.Default.ConnectionString; + } + } + + private void btnLoadData_Click(object sender, EventArgs e) { + try { + this.LoadData(); + } catch (Exception ex) { + MessageBox.Show("Es ist ein Fehler aufgetreten: " + ex.Message); + } + } + + private void LoadData() { + this.lsvLogEntries.Items.Clear(); + using (var conn = new MySqlConnection(this.txtConnectionString.Text)) { + conn.Open(); + using (var cmd = conn.CreateCommand()) { + cmd.CommandText = "select id, pod, location, hostname, severity, timestamp, message from v_logentries order by timestamp"; + using (var reader = cmd.ExecuteReader()) { + while (reader.Read()) { + var item = lsvLogEntries.Items.Add(reader.GetValue(0).ToString()); + for (var i = 1; i < 7; i++) { + var data = reader.GetValue(i); + item.SubItems.Add((data == null ? "" : data.ToString())); + } + } + } + } + } + } + + private void btnLogClear_Click(object sender, EventArgs e) { + try { + using (var conn = new MySqlConnection(this.txtConnectionString.Text)) { + conn.Open(); + foreach (ListViewItem row in this.lsvLogEntries.SelectedItems) { + using (var cmd = conn.CreateCommand()) { + cmd.CommandText = "LogClear"; + cmd.CommandType = CommandType.StoredProcedure; + cmd.Parameters.AddWithValue("@Id", Convert.ToInt32(row.SubItems[0].Text)); + cmd.ExecuteNonQuery(); + } + } + } + this.LoadData(); + } catch (Exception ex) { + MessageBox.Show("Es ist ein Fehler aufgetreten: " + ex.Message); + } + } + + private void Form1_FormClosing(object sender, FormClosingEventArgs e) { + Settings.Default.ConnectionString = this.txtConnectionString.Text; + Settings.Default.Save(); + } + } +} diff --git a/MonitoringClient/Source/MonitoringClient/Form1.resx b/MonitoringClient/Source/MonitoringClient/Form1.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/MonitoringClient/Source/MonitoringClient/Form1.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/MonitoringClient/Source/MonitoringClient/Lib/MySql.Data.dll b/MonitoringClient/Source/MonitoringClient/Lib/MySql.Data.dll new file mode 100644 index 0000000..0c7b2bb Binary files /dev/null and b/MonitoringClient/Source/MonitoringClient/Lib/MySql.Data.dll differ diff --git a/MonitoringClient/Source/MonitoringClient/MonitoringClient.csproj b/MonitoringClient/Source/MonitoringClient/MonitoringClient.csproj new file mode 100644 index 0000000..703200d --- /dev/null +++ b/MonitoringClient/Source/MonitoringClient/MonitoringClient.csproj @@ -0,0 +1,91 @@ + + + + + Debug + AnyCPU + {ED6D9A70-6FBD-44A8-AA32-EAC5892C84B6} + WinExe + Properties + MonitoringClient + MonitoringClient + v4.0 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + False + Lib\MySql.Data.dll + + + + + + + + + + + + + + + + Form + + + Form1.cs + + + + + Form1.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + \ No newline at end of file diff --git a/MonitoringClient/Source/MonitoringClient/Program.cs b/MonitoringClient/Source/MonitoringClient/Program.cs new file mode 100644 index 0000000..57a54f5 --- /dev/null +++ b/MonitoringClient/Source/MonitoringClient/Program.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Windows.Forms; + +namespace MonitoringClient { + static class Program { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} diff --git a/MonitoringClient/Source/MonitoringClient/Properties/AssemblyInfo.cs b/MonitoringClient/Source/MonitoringClient/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..5a284e3 --- /dev/null +++ b/MonitoringClient/Source/MonitoringClient/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("MonitoringClient")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("MonitoringClient")] +[assembly: AssemblyCopyright("Copyright © 2015")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("14248963-362d-42d5-b0ed-4188a7511e36")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/MonitoringClient/Source/MonitoringClient/Properties/Resources.Designer.cs b/MonitoringClient/Source/MonitoringClient/Properties/Resources.Designer.cs new file mode 100644 index 0000000..dfcaee4 --- /dev/null +++ b/MonitoringClient/Source/MonitoringClient/Properties/Resources.Designer.cs @@ -0,0 +1,62 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.34209 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace MonitoringClient.Properties { + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if ((resourceMan == null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MonitoringClient.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/MonitoringClient/Source/MonitoringClient/Properties/Resources.resx b/MonitoringClient/Source/MonitoringClient/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/MonitoringClient/Source/MonitoringClient/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/MonitoringClient/Source/MonitoringClient/Properties/Settings.Designer.cs b/MonitoringClient/Source/MonitoringClient/Properties/Settings.Designer.cs new file mode 100644 index 0000000..5778c6e --- /dev/null +++ b/MonitoringClient/Source/MonitoringClient/Properties/Settings.Designer.cs @@ -0,0 +1,38 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.34209 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace MonitoringClient.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("")] + public string ConnectionString { + get { + return ((string)(this["ConnectionString"])); + } + set { + this["ConnectionString"] = value; + } + } + } +} diff --git a/MonitoringClient/Source/MonitoringClient/Properties/Settings.settings b/MonitoringClient/Source/MonitoringClient/Properties/Settings.settings new file mode 100644 index 0000000..bfa61bf --- /dev/null +++ b/MonitoringClient/Source/MonitoringClient/Properties/Settings.settings @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/MonitoringClient/Source/MonitoringClient/app.config b/MonitoringClient/Source/MonitoringClient/app.config new file mode 100644 index 0000000..cf2f6f0 --- /dev/null +++ b/MonitoringClient/Source/MonitoringClient/app.config @@ -0,0 +1,15 @@ + + + + +
+ + + + + + + + + + \ No newline at end of file diff --git a/MySQL/Skript_DDL.sql b/MySQL/Skript_DDL.sql new file mode 100644 index 0000000..37f0b80 --- /dev/null +++ b/MySQL/Skript_DDL.sql @@ -0,0 +1,202 @@ +DROP DATABASE IF EXISTS inventarisierungsloesung; + +CREATE DATABASE IF NOT EXISTS Inventarisierungsloesung +CHARACTER SET utf8; + +USE Inventarisierungsloesung; + +CREATE TABLE IF NOT EXISTS Town ( +town_id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, +zip INT UNSIGNED NOT NULL, +town VARCHAR(100)); + +CREATE TABLE IF NOT EXISTS Address ( +address_id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, +town_fk INT UNSIGNED NOT NULL, +streetname VARCHAR(100) NOT NULL, +streetnumber VARCHAR(25) NOT NULL, +country VARCHAR(45) NOT NULL, +additive VARCHAR(45), +po_Box INT UNSIGNED, +FOREIGN KEY (town_fk) REFERENCES Town(town_id)ON DELETE CASCADE +); + +CREATE TABLE IF NOT EXISTS Person ( +person_id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, +firstname VARCHAR(45) NOT NULL, +lastname VARCHAR(45) NOT NULL); + +CREATE Table IF NOT EXISTS Kundenkonto ( +kundenkonto_id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT); + +CREATE Table IF NOT EXISTS Customer ( +person_fk INT UNSIGNED NOT NULL, +address_fk INT UNSIGNED NOT NULL, +kundenkonto_fk INT UNSIGNED NOT NULL, +tel VARCHAR(20), +eMail VARCHAR(30), +url VARCHAR(30), +FOREIGN KEY (person_fk) REFERENCES Person(Person_id) ON DELETE CASCADE, +FOREIGN KEY (address_fk) REFERENCES Address(address_id) ON DELETE CASCADE, +FOREIGN KEY (kundenkonto_fk) REFERENCES Kundenkonto(kundenkonto_id) ON DELETE CASCADE); + +CREATE TABLE IF NOT EXISTS Location ( +location_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, +address_fk INT UNSIGNED NOT NULL, +designation VARCHAR(45) NOT NULL, +building INT UNSIGNED NOT NULL, +room INT UNSIGNED NOT NULL, +FOREIGN KEY (address_fk) REFERENCES Address(address_id)ON DELETE CASCADE +); + +CREATE TABLE IF NOT EXISTS Contact ( +contact_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, +person_fk INT UNSIGNED NOT NULL, +priority ENUM('First Priority','Second Priority','Emergency Contact') NOT NULL, +FOREIGN KEY (person_fk) REFERENCES Person(person_id)ON DELETE CASCADE +); + + +CREATE TABLE IF NOT EXISTS PointOfDelivery ( +pod_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, +customer_person_fk INT UNSIGNED NOT NULL, +contact_person_fk INT UNSIGNED NOT NULL, +location_fk INT UNSIGNED NOT NULL, +designation VARCHAR(45), +timezone TIME NOT NULL, +timeZonePositiv TINYINT NOT NULL, +ntpServerIp VARCHAR(20), +FOREIGN KEY (`customer_person_fk`) REFERENCES `customer`(`person_fk`)ON DELETE CASCADE, +FOREIGN KEY (`contact_person_fk`) REFERENCES `contact`(`contact_id`)ON DELETE CASCADE, +FOREIGN KEY (`location_fk`) REFERENCES `location`(`location_id`) ON DELETE CASCADE +); + +CREATE Table IF NOT EXISTS DevicesTypes ( +deviceTypes_id INT UNSIGNED NOT NULL AUTO_INCREMENT, +manifacture VARCHAR(255) NOT NULL, +model VARCHAR(255) NOT NULL, +version VARCHAR(255) NOT NULL, +PRIMARY KEY(deviceTypes_id) +); + +CREATE Table IF NOT EXISTS Devices ( +device_id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +location_fk INT UNSIGNED NOT NULL, +deviceTypes_fk INT UNSIGNED NOT NULL, +inventoryDate DATE NOT NULL, +deactivateDate DATE NOT NULL, +hostname VARCHAR(255), +domain VARCHAR(255), +description VARCHAR(255), +FOREIGN KEY (location_fk) REFERENCES Location(location_id) ON DELETE CASCADE, +FOREIGN KEY (deviceTypes_fk) REFERENCES DevicesTypes(deviceTypes_id) ON DELETE CASCADE +); + +CREATE Table IF NOT EXISTS Operatingsystem ( +operatingsystem_id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +operatingsystemName VARCHAR(255) NOT NULL, +model VARCHAR(255) NOT NULL, +version VARCHAR(255) +); + +CREATE Table IF NOT EXISTS DevicesTypes_has_operatingsystem ( +deviceTypes_fk INT UNSIGNED NOT NULL, +operatingsystem_fk INT UNSIGNED NOT NULL, +PRIMARY KEY(deviceTypes_fk,operatingsystem_fk), +FOREIGN KEY (deviceTypes_fk) REFERENCES DevicesTypes(deviceTypes_id) ON DELETE CASCADE, +FOREIGN KEY (operatingsystem_fk) REFERENCES Operatingsystem(operatingsystem_id) ON DELETE CASCADE +); + +CREATE Table IF NOT EXISTS Log ( +log_id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +device_fk INT UNSIGNED NOT NULL, +timestamp DATETIME NOT NULL, +logMessage VARCHAR(255) NOT NULL, +level ENUM('Low','Middle','High') NOT NULL, +FOREIGN KEY (device_fk) REFERENCES Devices(device_id) ON DELETE CASCADE +); + +CREATE TABLE IF NOT EXISTS Network ( + network_id INT NOT NULL AUTO_INCREMENT, + subnet VARCHAR(15) NOT NULL, + mask VARCHAR(15) NOT NULL, + vlan INT NOT NULL DEFAULT 1, + description VARCHAR(255) NULL, + PRIMARY KEY (network_id)); + +CREATE TABLE IF NOT EXISTS DeviceTypes ( + deviceTypes_id INT NOT NULL AUTO_INCREMENT, + manifacturer VARCHAR(255) NOT NULL, + model VARCHAR(255) NOT NULL, + version VARCHAR(255) NULL, + PRIMARY KEY (deviceTypes_id) + ); + + +CREATE TABLE IF NOT EXISTS Credentials ( + credentials_id INT UNSIGNED NOT NULL AUTO_INCREMENT, + benutzername VARCHAR(255) NOT NULL, + passwort VARCHAR(255) NOT NULL, + snmp VARCHAR(255) NOT NULL, + PRIMARY KEY (credentials_id) + ); + +CREATE TABLE IF NOT EXISTS Interfaces ( + interface_id INT UNSIGNED NOT NULL AUTO_INCREMENT, + network_id_fk INT NOT NULL, + devices_id_fk INT UNSIGNED NOT NULL, + ip_adress_v4 VARCHAR(15) NOT NULL, + isFullDuplex BIT(1) NOT NULL DEFAULT 1, + bandwith INT NULL, + description VARCHAR(255) NULL, + PRIMARY KEY (interface_id), + FOREIGN KEY (network_id_fk) REFERENCES Network (network_id)ON DELETE CASCADE, + FOREIGN KEY (devices_id_fk) REFERENCES Devices (device_id)ON DELETE CASCADE + ); + + CREATE TABLE IF NOT EXISTS Abrechnung ( + abrechnung_id INT UNSIGNED NOT NULL AUTO_INCREMENT, + kundenkonto_fk INT UNSIGNED NOT NULL, + location_fk INT UNSIGNED NOT NULL, + device_fk INT UNSIGNED NOT NULL, + interface_fk INT UNSIGNED NOT NULL, + PRIMARY KEY (abrechnung_id), + FOREIGN KEY (kundenkonto_fk) REFERENCES Kundenkonto (kundenkonto_id)ON DELETE CASCADE, + FOREIGN KEY (location_fk) REFERENCES Location (location_id)ON DELETE CASCADE, + FOREIGN KEY (device_fk) REFERENCES Devices (device_id)ON DELETE CASCADE, + FOREIGN KEY (interface_fk) REFERENCES Interfaces (interface_id)ON DELETE CASCADE + ); + +CREATE TABLE IF NOT EXISTS SoftwareDienstleistung ( + software_id INT NOT NULL AUTO_INCREMENT, + stundenaufwand INT NOT NULL, + abrechung_fk INT UNSIGNED NOT NULL, + PRIMARY KEY (software_id), + Foreign Key (abrechung_fk) REFERENCES Abrechnung(abrechnung_id) ON DELETE CASCADE); + +CREATE TABLE IF NOT EXISTS Produktegruppe ( + produktegruppe_id INT NOT NULL AUTO_INCREMENT, + hardware VARCHAR(255), + software VARCHAR(255), + sonstigeArtikel VARCHAR(255), + abrechung_fk INT UNSIGNED NOT NULL, + PRIMARY KEY (produktegruppe_id), + Foreign Key (abrechung_fk) REFERENCES Abrechnung(abrechnung_id)ON DELETE CASCADE + ); + +CREATE TABLE IF NOT EXISTS Produkte ( + artikelnummer_id INT NOT NULL AUTO_INCREMENT, + artikelname VARCHAR(255) NOT NULL, + preis FLOAT NOT NULL, + produktegruppe_fk INT NOT NULL, + PRIMARY KEY (artikelnummer_id), + Foreign Key (produktegruppe_fk) REFERENCES Produktegruppe(produktegruppe_id)ON DELETE CASCADE + ); + + CREATE TABLE IF NOT EXISTS Devices_has_Credentials ( + devices_devices_id INT UNSIGNED NOT NULL, + credentials_credentials_id INT UNSIGNED NOT NULL, + PRIMARY KEY (devices_devices_id, credentials_credentials_id), + FOREIGN KEY (devices_devices_id) REFERENCES Devices (device_id) ON DELETE CASCADE, + FOREIGN KEY (credentials_credentials_id) REFERENCES Credentials (credentials_id) ON DELETE CASCADE + ); \ No newline at end of file diff --git a/MySQL/Skript_DML.sql b/MySQL/Skript_DML.sql new file mode 100644 index 0000000..fb980fe --- /dev/null +++ b/MySQL/Skript_DML.sql @@ -0,0 +1,155 @@ +USE inventarisierungsloesung; + +INSERT INTO town(zip, town) +VALUES +('9043', 'Trogen'), +('9999', 'Hobbingen'), +('9000', 'St. Gallen'), +('6000', 'Luzern'), +('8400', 'Winterthur'); + +INSERT INTO address(town_fk, streetname, streetnumber, country, additive, po_box) +VALUES +(2,'Auenlandstrasse','5b','Auenland', 'Postkasten ist hinter Höhle' , null), +(1,'Befang','5','Schweiz', null , null), +(3,'Zürcherstrasse','300C','Schweiz', null , '203'), +(4,'Löwenstrasse','26','Schweiz', null , '100'), +(5,'Rudolfstrasse','17A','Schweiz', null , '100'), +(3,'Langgass','35A','Schweiz', null , null); + + +INSERT INTO person(firstname, lastname) +VALUES +('Nina','Schmid'), +('Bilbo','Beutlin'), +('Patrick','Keist'), +('Larissa', 'Fitze'), +('Francesco' , 'Rauseo'), +('Ronny','Wyss'), +('Max','Muster'); + +INSERT INTO kundenkonto(kundenkonto_id) +VALUES +(1),(2),(3),(4),(5),(6),(7),(8); + +INSERT INTO customer(person_fk, address_fk, kundenkonto_fk, tel, eMail, url) +VALUES +(1, 2, 3, '079 666 20 14', 'nina.schmid@test.ch','www.nina.ch'), +(2, 1, 1, 'Dose mit Schnur', 'bilbo@auenland.xx',null), +(3, 3, 2, '078 878 90 43', 'p.keist@hotmail.com',null), +(6, 4, 4, '077 777 77 77', 'ronny@wyss.ch',null); + +INSERT INTO contact( person_fk, priority) +VALUES +(2,3), +(1,2), +(3,1), +(4,2), +(5,1); + +INSERT INTO location( address_fk, designation, building, room) +VALUES +(1, 'Vertriebszentrum Tabak', 2, 4), +(2, 'Absteige',5,9), +(3, 'Consult & Pepper', 6,9); + + +INSERT INTO pointofdelivery(customer_person_fk, contact_person_fk, location_fk, designation, timezone, timeZonePositiv, ntpServerIp) +VALUES +(2,2,1,'Auenland','10:00:00',1, '1.1.1.10'), +(1,1,3, 'Consult & Pepper Trogen', '01:00:00', 1 , '178.198.222.68'), +(3,4,2,'ZbW', '01:00:00', 1 , '192.168.1.1'); + +INSERT INTO Network (network_id, subnet, mask, vlan, description) +VALUES +(1,'10.36.0.0','255.255.0.0',1,'Kunde xy'), +(2,'10.8.0.0','255.255.0.0',1,''), +(3,'172.129.0.0','255.255.255.0',1,'Test'), +(4,'192.168.1.0','255.255.255.0',1,'Labor'), +(5,'192.168.128.0','255.255.255.127',1,'Integration'); + +INSERT INTO DevicesTypes(manifacture, model, version) +VALUES +('Cisco','Router',''), +('Avaya','PBX',''), +('Nortel','PBX',''), +('Siemens','Telephon',''), +('Cisco','FireWall',''); + + +INSERT INTO Devices (location_fk, deviceTypes_fk, inventoryDate, deactivateDate, hostname, domain, description) +VALUES +(1,1,'2018-12-31','2019-12-31','CiscoR1','ch.zbw','Keller'), +(1,1,'2007-10-29','2008-10-29','CSTA003','ch.zbw','OG6'), +(2,1,'2018-12-10','2018-02-12','TelCo099','ch.aruper','RZ'), +(3,1,'2018-06-06','2019-02-12','CiscoR006','ch.scs','Keller'), +(1,1,'2018-02-01','2020-12-02','Cisco-PRT-032','ch.zbw','Kantine'); + +INSERT INTO Interfaces (interface_id, network_id_fk, devices_id_fk, ip_adress_v4, isFullDuplex, bandwith, description) +VALUES +(1,3,1,'172.129.1.5',1,10000,''), +(2,3,4,'172.129.1.6',1,10000,''), +(3,1,5,'10.36.0.253',1,10000,''), +(4,5,4,'192.168.128.192',1,10000,''), +(5,3,3,'172.129.5.9',1,100,''); + +INSERT INTO operatingsystem (operatingsystem_id, operatingsystemName, model, version) +VALUES +(1,'CISCO IO','Cisco','9.5'), +(2,'AVAYALX','Linux','19.4.0.1'), +(3,'Unify','Debian','9.2'), +(4,'NOOS','RH','0.2.8'), +(5,'Linux','RedHead','17.3'); + +INSERT INTO DevicesTypes_has_operatingsystem (deviceTypes_fk, operatingsystem_fk) +VALUES +(1,1), +(2,2), +(3,4), +(4,3), +(5,1); + +INSERT INTO Log (logMessage, timestamp, level, device_fk) +VALUES +('Loged In',now(),'Low',1), +('Loged Out',now(),'Low',1), +('Loged In',now(),'Low',2), +('Virus detected',now(),'High',3) +; + +INSERT INTO Abrechnung (kundenkonto_fk, location_fk, device_fk, interface_fk) +VALUES +(1,1,1,1), +(1,1,1,1); + +INSERT INTO SoftwareDienstleistung (stundenaufwand, abrechung_fk) +VALUES +(240,1); + +INSERT INTO Produktegruppe (hardware, software, sonstigeArtikel, abrechung_fk) +VALUES +('Hardware','PP','ss',1), +('Hardware','PP','ss',1), +('HH','Software','ss',2), +('HH','SS','sonstigeArtikel',1); + +INSERT INTO Produkte (artikelname, preis, produktegruppe_fk) +VALUES +('Laptop',50, 1), +('Bildschirm',150, 1), +('AdobeReader',20, 1), +('Bürostuhl',10, 1); + +INSERT INTO Credentials (credentials_id, benutzername,passwort,snmp) +VALUES +(1,'Larissa','1111','snmp1'), +(2,'Patrick','1111','snmp2'), +(3,'Francesco','1111','snmp3'), +(4,'Ronny','1111','snmp4'); + +INSERT INTO Devices_has_Credentials (Devices_devices_id, credentials_credentials_id) +VALUES +(1,1), +(2,2), +(3,4), +(4,3); \ No newline at end of file diff --git a/MySQL/erm.mwb b/MySQL/erm.mwb new file mode 100644 index 0000000..114bfc0 Binary files /dev/null and b/MySQL/erm.mwb differ diff --git a/Semesterarbeit_S2.pdf b/Semesterarbeit_S2.pdf new file mode 100644 index 0000000..db168f8 Binary files /dev/null and b/Semesterarbeit_S2.pdf differ