/*M!999999\- enable the sandbox mode */ 
-- MariaDB dump 10.19  Distrib 10.11.14-MariaDB, for debian-linux-gnu (x86_64)
--
-- Host: localhost    Database: skyddsrond
-- ------------------------------------------------------
-- Server version	10.11.14-MariaDB-0ubuntu0.24.04.1

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Current Database: `skyddsrond`
--

CREATE DATABASE /*!32312 IF NOT EXISTS*/ `skyddsrond` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci */;

USE `skyddsrond`;

--
-- Table structure for table `category`
--

DROP TABLE IF EXISTS `category`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `category` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `category_name` varchar(255) NOT NULL,
  `sort_order` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `category`
--

LOCK TABLES `category` WRITE;
/*!40000 ALTER TABLE `category` DISABLE KEYS */;
/*!40000 ALTER TABLE `category` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `frågor`
--

DROP TABLE IF EXISTS `frågor`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `frågor` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `fråga` text NOT NULL,
  `skapad_tid` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=33 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `frågor`
--

LOCK TABLES `frågor` WRITE;
/*!40000 ALTER TABLE `frågor` DISABLE KEYS */;
INSERT INTO `frågor` VALUES
(8,'Är bullernivån från kranen acceptabel enligt arbetsmiljökrav?','2024-11-29 20:49:23'),
(9,'Finns det skyltar som varnar för farliga områden runt kranen?','2024-11-29 20:52:07'),
(10,'Är utrymningsvägar tydligt markerade och fria från hinder?','2024-11-29 20:53:52'),
(11,'Finns det en fungerande nödstopp på kranen?','2024-11-29 20:57:08'),
(12,'Är alla kranens säkerhetssystem i fullgott skick?','2024-11-29 20:58:52'),
(13,'Är vajrar, kedjor och andra lyftkomponenter fria från slitage eller skador?','2024-11-29 21:03:45'),
(14,'Är bromsarna och andra mekaniska delar i god funktion?','2024-11-30 10:50:35'),
(15,'Fungerar kranens sensorer och mätinstrument korrekt?','2024-11-30 10:56:43'),
(16,'Är hytten ergonomiskt utformad för långa arbetspass?','2024-11-30 10:59:07'),
(17,'Är hytten ergonomiskt utformad för långa arbetspass?','2024-11-30 10:59:12'),
(18,'Finns det tillgång till luftkonditionering och värme i hytten?','2024-11-30 11:00:31'),
(19,'Är sikten från hytten fri från hinder och smutsiga fönster?','2024-11-30 11:06:55'),
(20,'Är operatörens stol justerbar och i bra skick?','2024-11-30 11:07:25'),
(21,'Finns det en säker tillgång till hytten (t.ex. trappor, stegar med halkskydd)?','2024-11-30 11:08:24'),
(22,'Är lastutrustningen (t.ex. spreaders) i bra skick?','2024-11-30 11:09:45'),
(23,'Finns det tillräcklig kommunikation mellan operatör och markpersonal?','2024-11-30 11:13:08'),
(24,'Är containrarna korrekt staplade och säkrade innan lyft?','2024-11-30 11:13:47'),
(25,'Finns det risk för svajande last vid lyft?','2024-11-30 11:14:31'),
(26,'Är lyfthastigheten säker och under kontroll?','2024-11-30 11:15:04'),
(27,'Använder personalen korrekt personlig skyddsutrustning (hjälm, sele, etc.)?','2024-11-30 11:15:38'),
(28,'Är alla fallskyddssystem regelbundet inspekterade och certifierade?','2024-11-30 11:16:13'),
(29,'Finns det säkerhetslinor och förankringspunkter vid arbete på höjd?','2024-11-30 11:17:27'),
(30,'Har kranen nyligen genomgått sin periodiska säkerhetskontroll?','2024-11-30 11:29:33'),
(31,'Är alla underhållsprotokoll och inspektionsdokument uppdaterade?','2024-11-30 11:29:57'),
(32,'Finns det riskbedömningar för olika arbetsmoment med kranen?','2024-11-30 11:30:16');
/*!40000 ALTER TABLE `frågor` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `inspection_answers`
--

DROP TABLE IF EXISTS `inspection_answers`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `inspection_answers` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `inspection_id` int(11) DEFAULT NULL,
  `question_id` int(11) DEFAULT NULL,
  `answer` enum('Ja','Nej','Ej relevant') DEFAULT NULL,
  `risk_level` enum('Låg','Medel','Hög') DEFAULT NULL,
  `risk_description` text DEFAULT NULL,
  `action` text DEFAULT NULL,
  `responsible` varchar(255) DEFAULT NULL,
  `due_date` date DEFAULT NULL,
  `control_date` date DEFAULT NULL,
  `is_correct` tinyint(1) DEFAULT NULL,
  `status` text DEFAULT NULL,
  `info` longtext DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `inspection_id` (`inspection_id`),
  KEY `question_id` (`question_id`),
  CONSTRAINT `inspection_answers_ibfk_1` FOREIGN KEY (`inspection_id`) REFERENCES `inspections` (`id`),
  CONSTRAINT `inspection_answers_ibfk_2` FOREIGN KEY (`question_id`) REFERENCES `questions` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=230 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `inspection_answers`
--

LOCK TABLES `inspection_answers` WRITE;
/*!40000 ALTER TABLE `inspection_answers` DISABLE KEYS */;
/*!40000 ALTER TABLE `inspection_answers` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `inspection_images`
--

DROP TABLE IF EXISTS `inspection_images`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `inspection_images` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `inspection_answer_id` int(11) DEFAULT NULL,
  `image_path` longtext DEFAULT NULL,
  `uploaded_at` timestamp NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `inspection_answer_id` (`inspection_answer_id`),
  CONSTRAINT `inspection_images_ibfk_1` FOREIGN KEY (`inspection_answer_id`) REFERENCES `inspection_answers` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=57 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `inspection_images`
--

LOCK TABLES `inspection_images` WRITE;
/*!40000 ALTER TABLE `inspection_images` DISABLE KEYS */;
/*!40000 ALTER TABLE `inspection_images` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `inspection_participants`
--

DROP TABLE IF EXISTS `inspection_participants`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `inspection_participants` (
  `inspection_id` int(11) NOT NULL,
  `participant_id` int(11) NOT NULL,
  KEY `inspection_id` (`inspection_id`),
  KEY `participant_id` (`participant_id`),
  CONSTRAINT `inspection_participants_ibfk_1` FOREIGN KEY (`inspection_id`) REFERENCES `inspections` (`id`) ON DELETE CASCADE,
  CONSTRAINT `inspection_participants_ibfk_2` FOREIGN KEY (`participant_id`) REFERENCES `participants` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `inspection_participants`
--

LOCK TABLES `inspection_participants` WRITE;
/*!40000 ALTER TABLE `inspection_participants` DISABLE KEYS */;
/*!40000 ALTER TABLE `inspection_participants` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `inspections`
--

DROP TABLE IF EXISTS `inspections`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `inspections` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `inspection_date` date DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `location` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=46 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `inspections`
--

LOCK TABLES `inspections` WRITE;
/*!40000 ALTER TABLE `inspections` DISABLE KEYS */;
/*!40000 ALTER TABLE `inspections` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `participants`
--

DROP TABLE IF EXISTS `participants`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `participants` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(100) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `participants`
--

LOCK TABLES `participants` WRITE;
/*!40000 ALTER TABLE `participants` DISABLE KEYS */;
/*!40000 ALTER TABLE `participants` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `questions`
--

DROP TABLE IF EXISTS `questions`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `questions` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `question_text` text DEFAULT NULL,
  `category` varchar(100) DEFAULT 'Allmänt',
  `alternativ` varchar(20) NOT NULL,
  `sort_order` int(11) DEFAULT 0,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=184 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `questions`
--

LOCK TABLES `questions` WRITE;
/*!40000 ALTER TABLE `questions` DISABLE KEYS */;
/*!40000 ALTER TABLE `questions` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2026-05-17  0:00:03
