ganti format table

This commit is contained in:
sas.fajri
2025-04-24 14:39:28 +07:00
parent f481cc76f1
commit a2a700280b
11 changed files with 2078 additions and 1397 deletions

View File

@@ -7,60 +7,56 @@
-- Master Area Types
CREATE TABLE IF NOT EXISTS master_area_types (
area_type_id INT PRIMARY KEY,
area_type_name VARCHAR(100) NOT NULL,
description TEXT,
status BOOLEAN DEFAULT TRUE,
input_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
input_user VARCHAR(50)
MasterAreaTypeID INT PRIMARY KEY,
MasterAreaTypeName VARCHAR(100) NOT NULL,
MasterAreaTypeDescription TEXT,
MasterAreaTypeIsActive BOOLEAN DEFAULT TRUE,
MasterAreaTypeCreatedUserID INT
);
-- Master Noise Quality Standards
CREATE TABLE IF NOT EXISTS master_noise_standards (
standard_id INT PRIMARY KEY,
regulation_id INT NOT NULL,
area_type_id INT NOT NULL,
standard_value DECIMAL(5, 1) NOT NULL,
unit VARCHAR(10) DEFAULT 'dB(A)',
measurement_time VARCHAR(50),
description TEXT,
status BOOLEAN DEFAULT TRUE,
input_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
input_user VARCHAR(50),
FOREIGN KEY (regulation_id) REFERENCES master_regulations(regulation_id),
FOREIGN KEY (area_type_id) REFERENCES master_area_types(area_type_id)
MasterNoiseStandardID INT PRIMARY KEY,
MasterRegulationID INT NOT NULL,
MasterAreaTypeID INT NOT NULL,
MasterNoiseStandardValue DECIMAL(5, 1) NOT NULL,
MasterNoiseStandardUnit VARCHAR(10) DEFAULT 'dB(A)',
MasterNoiseStandardMeasurementTime VARCHAR(50),
MasterNoiseStandardDescription TEXT,
MasterNoiseStandardIsActive BOOLEAN DEFAULT TRUE,
MasterNoiseStandardCreatedUserID INT,
FOREIGN KEY (MasterRegulationID) REFERENCES master_regulations(regulation_id),
FOREIGN KEY (MasterAreaTypeID) REFERENCES master_area_types(MasterAreaTypeID)
);
-- Master Noise Measurement Methods
CREATE TABLE IF NOT EXISTS master_noise_methods (
method_id INT PRIMARY KEY,
method_code VARCHAR(50) NOT NULL,
method_name VARCHAR(255) NOT NULL,
description TEXT,
standard_reference VARCHAR(100),
status BOOLEAN DEFAULT TRUE,
input_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
input_user VARCHAR(50)
MasterNoiseMethodID INT PRIMARY KEY,
MasterNoiseMethodCode VARCHAR(50) NOT NULL,
MasterNoiseMethodName VARCHAR(255) NOT NULL,
MasterNoiseMethodDescription TEXT,
MasterNoiseMethodStandardReference VARCHAR(100),
MasterNoiseMethodIsActive BOOLEAN DEFAULT TRUE,
MasterNoiseMethodCreatedUserID INT
);
-- Master Noise Measurement Equipment
CREATE TABLE IF NOT EXISTS master_noise_equipment (
equipment_id INT PRIMARY KEY,
equipment_code VARCHAR(20) NOT NULL,
equipment_name VARCHAR(100) NOT NULL,
equipment_type VARCHAR(50),
brand VARCHAR(100),
model VARCHAR(100),
serial_number VARCHAR(100),
accuracy_type VARCHAR(20), -- Type 0, 1, 2 for SLM
specifications TEXT,
calibration_date DATE,
next_calibration_date DATE,
calibration_status VARCHAR(20),
certificate_file VARCHAR(255),
status BOOLEAN DEFAULT TRUE,
input_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
input_user VARCHAR(50)
MasterNoiseEquipmentID INT PRIMARY KEY,
MasterNoiseEquipmentCode VARCHAR(20) NOT NULL,
MasterNoiseEquipmentName VARCHAR(100) NOT NULL,
MasterNoiseEquipmentType VARCHAR(50),
MasterNoiseEquipmentBrand VARCHAR(100),
MasterNoiseEquipmentModel VARCHAR(100),
MasterNoiseEquipmentSerialNumber VARCHAR(100),
MasterNoiseEquipmentAccuracyType VARCHAR(20), -- Type 0, 1, 2 for SLM
MasterNoiseEquipmentSpecifications TEXT,
MasterNoiseEquipmentCalibrationDate DATE,
MasterNoiseEquipmentNextCalibrationDate DATE,
MasterNoiseEquipmentCalibrationStatus VARCHAR(20),
MasterNoiseEquipmentCertificateFile VARCHAR(255),
MasterNoiseEquipmentIsActive BOOLEAN DEFAULT TRUE,
MasterNoiseEquipmentCreatedUserID INT
);
-- ------------------------------------------------------------------------------
@@ -130,10 +126,10 @@ CREATE TABLE IF NOT EXISTS trx_noise_measurement_details (
input_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
input_user VARCHAR(50),
FOREIGN KEY (measurement_id) REFERENCES trx_noise_measurement_results(measurement_id),
FOREIGN KEY (area_type_id) REFERENCES master_area_types(area_type_id),
FOREIGN KEY (method_id) REFERENCES master_noise_methods(method_id),
FOREIGN KEY (equipment_id) REFERENCES master_noise_equipment(equipment_id),
FOREIGN KEY (standard_id) REFERENCES master_noise_standards(standard_id)
FOREIGN KEY (area_type_id) REFERENCES master_area_types(MasterAreaTypeID),
FOREIGN KEY (method_id) REFERENCES master_noise_methods(MasterNoiseMethodID),
FOREIGN KEY (equipment_id) REFERENCES master_noise_equipment(MasterNoiseEquipmentID),
FOREIGN KEY (standard_id) REFERENCES master_noise_standards(MasterNoiseStandardID)
);
-- Noise Control Recommendations
@@ -156,40 +152,57 @@ CREATE TABLE IF NOT EXISTS trx_noise_control_recommendations (
-- ------------------------------------------------------------------------------
-- Insert Data Master Area Types
INSERT INTO master_area_types (area_type_id, area_type_name, description, status, input_user)
VALUES
(1, 'Residential Areas', 'Residential housing and settlements', TRUE, 'admin'),
(2, 'Commercial and Trade Areas', 'Commercial and service areas, including offices', TRUE, 'admin'),
(3, 'Office and Commercial Areas', 'Office and commercial areas', TRUE, 'admin'),
(4, 'Industrial Areas', 'Manufacturing industrial areas', TRUE, 'admin'),
(5, 'Hospitals and Healthcare Facilities', 'Hospitals, health centers, and other healthcare facilities', TRUE, 'admin'),
(6, 'Schools and Educational Facilities', 'Educational areas including schools, madrasas, colleges', TRUE, 'admin'),
(7, 'Places of Worship', 'Worship areas such as mosques, churches, temples, and other religious buildings', TRUE, 'admin');
INSERT INTO master_area_types (
MasterAreaTypeID, MasterAreaTypeName, MasterAreaTypeDescription,
MasterAreaTypeIsActive, MasterAreaTypeCreatedUserID
) VALUES
(1, 'Residential Areas', 'Residential housing and settlements',
TRUE, 1),
(2, 'Commercial and Trade Areas', 'Commercial and service areas, including offices',
TRUE, 1),
(3, 'Office and Commercial Areas', 'Office and commercial areas',
TRUE, 1);
-- Insert Data Master Noise Standards
INSERT INTO master_noise_standards (standard_id, regulation_id, area_type_id, standard_value, unit, measurement_time, description, status, input_user)
VALUES
(1, 1, 1, 55.0, 'dB(A)', 'Leq 24 hours', 'Noise quality standard for residential areas', TRUE, 'admin'),
(2, 1, 2, 70.0, 'dB(A)', 'Leq 24 hours', 'Noise quality standard for commercial and trade areas', TRUE, 'admin'),
(3, 1, 3, 65.0, 'dB(A)', 'Leq 24 hours', 'Noise quality standard for office and commercial areas', TRUE, 'admin'),
(4, 1, 4, 70.0, 'dB(A)', 'Leq 24 hours', 'Noise quality standard for industrial areas', TRUE, 'admin'),
(5, 1, 5, 55.0, 'dB(A)', 'Leq 24 hours', 'Noise quality standard for hospitals and healthcare facilities', TRUE, 'admin'),
(6, 1, 6, 55.0, 'dB(A)', 'Leq during school hours', 'Noise quality standard for schools and educational facilities', TRUE, 'admin'),
(7, 1, 7, 55.0, 'dB(A)', 'Leq during worship times', 'Noise quality standard for places of worship', TRUE, 'admin');
INSERT INTO master_noise_standards (
MasterNoiseStandardID, MasterRegulationID, MasterAreaTypeID,
MasterNoiseStandardValue, MasterNoiseStandardUnit,
MasterNoiseStandardMeasurementTime, MasterNoiseStandardDescription,
MasterNoiseStandardIsActive, MasterNoiseStandardCreatedUserID
) VALUES
(1, 1, 1, 55.0, 'dB(A)', 'Leq 24 hours',
'Noise quality standard for residential areas', TRUE, 1),
(2, 1, 2, 70.0, 'dB(A)', 'Leq 24 hours',
'Noise quality standard for commercial and trade areas', TRUE, 1);
-- Insert Data Master Noise Measurement Methods
INSERT INTO master_noise_methods (method_id, method_code, method_name, description, standard_reference, status, input_user)
VALUES
(1, 'SNI-7231-2009', 'SNI 7231:2009 - Environmental Noise Measurement Method', 'Method for measuring environmental noise levels using Sound Level Meter', 'SNI 7231:2009', TRUE, 'admin'),
(2, 'KEPMEN-LH-48-1996', 'Ministry of Environment Decree No. 48 of 1996 - Appendix II', 'Noise level measurement method based on the Ministry of Environment Decree', 'Ministry of Environment Decree No.48 of 1996', TRUE, 'admin');
INSERT INTO master_noise_methods (
MasterNoiseMethodID, MasterNoiseMethodCode, MasterNoiseMethodName,
MasterNoiseMethodDescription, MasterNoiseMethodStandardReference,
MasterNoiseMethodIsActive, MasterNoiseMethodCreatedUserID
) VALUES
(1, 'SNI-7231-2009', 'SNI 7231:2009 - Environmental Noise Measurement Method',
'Method for measuring environmental noise levels using Sound Level Meter',
'SNI 7231:2009', TRUE, 1),
(2, 'KEPMEN-LH-48-1996', 'Ministry of Environment Decree No. 48 of 1996 - Appendix II',
'Noise level measurement method based on the Ministry of Environment Decree',
'Ministry of Environment Decree No.48 of 1996', TRUE, 1);
-- Insert Data Master Noise Measurement Equipment
INSERT INTO master_noise_equipment (equipment_id, equipment_code, equipment_name, equipment_type, brand, model, serial_number, accuracy_type, specifications, calibration_date, next_calibration_date, calibration_status, certificate_file, status, input_user)
VALUES
(1, 'SLM-01', 'Sound Level Meter', 'SLM', 'RION', 'NL-52', '12345678', 'Type 1', 'Range: 20-130 dB, Accuracy: ±1.0 dB, Frequency range: 20 Hz - 20 kHz', '2024-02-15', '2025-02-15', 'VALID', '/documents/calibration/slm_rion_2024.pdf', TRUE, 'admin'),
(2, 'CAL-01', 'Acoustic Calibrator', 'Calibrator', 'RION', 'NC-74', '87654321', 'Class 1', 'Calibration level: 94 dB, Accuracy: ±0.3 dB', '2024-02-15', '2025-02-15', 'VALID', '/documents/calibration/cal_rion_2024.pdf', TRUE, 'admin'),
(3, 'SLM-02', 'Sound Level Meter', 'SLM', 'Cirrus', 'CR171B', 'CR123456', 'Type 1', 'Range: 20-140 dB, Accuracy: ±0.5 dB, Frequency range: 10 Hz - 20 kHz', '2023-11-20', '2024-11-20', 'VALID', '/documents/calibration/slm_cirrus_2023.pdf', TRUE, 'admin'),
(4, 'WS-01', 'Weather Station', 'Weather Meter', 'Kestrel', '5500', 'KW123456', 'N/A', 'Wind speed, direction, temperature, humidity, pressure measurement', '2023-10-10', '2024-10-10', 'VALID', '/documents/calibration/weather_kestrel_2023.pdf', TRUE, 'admin');
INSERT INTO master_noise_equipment (
MasterNoiseEquipmentID, MasterNoiseEquipmentCode, MasterNoiseEquipmentName,
MasterNoiseEquipmentType, MasterNoiseEquipmentBrand,
MasterNoiseEquipmentModel, MasterNoiseEquipmentSerialNumber,
MasterNoiseEquipmentAccuracyType, MasterNoiseEquipmentSpecifications,
MasterNoiseEquipmentCalibrationDate, MasterNoiseEquipmentNextCalibrationDate,
MasterNoiseEquipmentCalibrationStatus, MasterNoiseEquipmentCertificateFile,
MasterNoiseEquipmentIsActive, MasterNoiseEquipmentCreatedUserID
) VALUES
(1, 'SLM-01', 'Sound Level Meter', 'SLM',
'RION', 'NL-52', '12345678', 'Type 1',
'Range: 20-130 dB, Accuracy: ±1.0 dB, Frequency range: 20 Hz - 20 kHz',
'2024-02-15', '2025-02-15', 'VALID',
'/documents/calibration/slm_rion_2024.pdf', TRUE, 1);
-- ------------------------------------------------------------------------------
-- Sample Data Insertion - Transaction Tables