diff --git a/MySQL/SP_v_logentries.sql b/MySQL/SP_v_logentries.sql new file mode 100644 index 0000000..a88b532 --- /dev/null +++ b/MySQL/SP_v_logentries.sql @@ -0,0 +1,19 @@ +# Stored Procedure bereinigung der quittierte Logs + +DELIMITER // +CREATE PROCEDURE LogClear +( + IN _logentries_id INT +) + +BEGIN + + DELETE FROM v_logentries + WHERE _logentreies_id = logentrie_id; + + UPDATE Log + SET is_acknowledged = 1 + WHERE log_is = _logentries_id; + +END // +DELIMITER ; \ No newline at end of file diff --git a/MySQL/Skript_DDL.sql b/MySQL/Skript_DDL.sql index d8ed81d..ece103e 100644 --- a/MySQL/Skript_DDL.sql +++ b/MySQL/Skript_DDL.sql @@ -148,6 +148,7 @@ device_fk INT UNSIGNED NOT NULL, timestamp DATETIME NOT NULL, logMessage VARCHAR(255) NOT NULL, level ENUM('Low','Middle','High') NOT NULL, +is_acknowledged TINYINT, FOREIGN KEY (device_fk) REFERENCES Device(device_id) ON DELETE CASCADE ); @@ -207,11 +208,54 @@ FOREIGN KEY (credentials_credentials_id) REFERENCES Credentials (credentials_id) ); CREATE TABLE IF NOT EXISTS v_logentries ( -logentrie_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, +v_logentries_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, pod VARCHAR(1000), location VARCHAR(1000) hostname VARCHAR(45), severity INT, timestamp TIMESTAMP; message VARCHAR(1000) -); \ No newline at end of file +); + + +# Stored Procedure bereinigung der quittierte Logs + +DELIMITER // +CREATE PROCEDURE LogClear +( + IN _logentries_id INT +) + +BEGIN + + DELETE FROM v_logentries + WHERE _logentreies_id = logentrie_id; + + UPDATE Log + SET is_acknowledged = 1 + WHERE log_is = _logentries_id; + +END // +DELIMITER ; + +# View für das anzeigen nicht belegter Interfaces +CREATE VIEW + view_freiesInterface (LocationName, Hostname, Portnummer, Medium, Geschwindigkeit) + AS + SELECT + CONCAT_WS(building, room), + device.hostname, + deviceport.description, + transportmedium.description, + bandwith + FROM + device INNER JOIN location + ON location_fk=location_id + INNER JOIN deviceport + ON device_fk = device_id + INNER JOIN transportmedium + ON device_fk = device_id + INNER JOIN interface + ON interface.device_fk = device_id + WHERE interface.is_in_use = 0 +; \ No newline at end of file diff --git a/MySQL/Skript_DML.sql b/MySQL/Skript_DML.sql index 0c66675..f271bd4 100644 --- a/MySQL/Skript_DML.sql +++ b/MySQL/Skript_DML.sql @@ -124,12 +124,12 @@ VALUES (4,3), (5,1); -INSERT INTO Log (logMessage, timestamp, level, device_fk) +INSERT INTO Log (logMessage, timestamp, level, is_acknowledged, device_fk) VALUES -('Loged In',now(),'Low',1), -('Loged Out',now(),'Low',1), -('Loged In',now(),'Low',2), -('Virus detected',now(),'High',3) +('Loged In',now(),'Low',0,1), +('Loged Out',now(),'Low'0,,1), +('Loged In',now(),'Low'0,,2), +('Virus detected',now(),'High'0,,3) ; INSERT INTO Abrechnung (kundenkonto_fk, location_fk, device_fk, interface_fk)