Skip to content

Instantly share code, notes, and snippets.

@jrichardsz
Forked from EnricoSteez/db.sql
Last active March 13, 2022 23:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrichardsz/e7da1b24cc737478412834893567c12c to your computer and use it in GitHub Desktop.
Save jrichardsz/e7da1b24cc737478412834893567c12c to your computer and use it in GitHub Desktop.
SIRS Database Creation
-- MySQL dump 10.13 Distrib 8.0.28, for Win64 (x86_64)
--
-- Host: localhost Database: main
-- ------------------------------------------------------
-- Server version 8.0.28
/*!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 */;
/*!50503 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 */;
--
-- Table structure for table `clinic_visits`
--
DROP TABLE IF EXISTS `clinic_visits`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `clinic_visits` (
`PatientID` int NOT NULL,
`VisitDate` datetime NOT NULL,
PRIMARY KEY (`PatientID`,`VisitDate`),
CONSTRAINT `clinic_visits_ibfk_1` FOREIGN KEY (`PatientID`) REFERENCES `medical_records` (`PatientID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `clinic_visits`
--
LOCK TABLES `clinic_visits` WRITE;
/*!40000 ALTER TABLE `clinic_visits` DISABLE KEYS */;
/*!40000 ALTER TABLE `clinic_visits` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `lab_results`
--
DROP TABLE IF EXISTS `lab_results`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `lab_results` (
`Id` int NOT NULL AUTO_INCREMENT,
`PatientID` int NOT NULL,
`Results` text NOT NULL,
PRIMARY KEY (`Id`),
KEY `PatientID` (`PatientID`),
CONSTRAINT `lab_results_ibfk_1` FOREIGN KEY (`PatientID`) REFERENCES `medical_records` (`PatientID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `lab_results`
--
LOCK TABLES `lab_results` WRITE;
/*!40000 ALTER TABLE `lab_results` DISABLE KEYS */;
/*!40000 ALTER TABLE `lab_results` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `medical_records`
--
DROP TABLE IF EXISTS `medical_records`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `medical_records` (
`PatientID` int NOT NULL AUTO_INCREMENT,
`NameSurname` varchar(45) NOT NULL DEFAULT '',
`email` varchar(45) NOT NULL DEFAULT '',
`HomeAddress` varchar(45) NOT NULL DEFAULT '',
`HealthNumber` int NOT NULL DEFAULT 0,
`HealthHistory` text NOT NULL DEFAULT '',
`Allergies` text NOT NULL DEFAULT '',
PRIMARY KEY (`PatientID`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 ;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `medical_records`
--
LOCK TABLES `medical_records` WRITE;
/*!40000 ALTER TABLE `medical_records` DISABLE KEYS */;
/*!40000 ALTER TABLE `medical_records` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `medications`
--
DROP TABLE IF EXISTS `medications`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `medications` (
`MedicationID` int NOT NULL,
`Medicine` varchar(45) NOT NULL DEFAULT '',
`PatientID` int NOT NULL,
`Quantity` varchar(45) NOT NULL DEFAULT '',
`Description` text NOT NULL DEFAULT '',
PRIMARY KEY (`MedicationID`),
KEY `PatientID` (`PatientID`),
CONSTRAINT `medications_ibfk_1` FOREIGN KEY (`PatientID`) REFERENCES `medical_records` (`PatientID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `medications`
--
LOCK TABLES `medications` WRITE;
/*!40000 ALTER TABLE `medications` DISABLE KEYS */;
/*!40000 ALTER TABLE `medications` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `problems`
--
DROP TABLE IF EXISTS `problems`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `problems` (
`ProblemID` int NOT NULL AUTO_INCREMENT,
`PatientID` int NOT NULL,
`ProblemDescription` text NOT NULL,
PRIMARY KEY (`ProblemID`),
KEY `PatientID` (`PatientID`),
CONSTRAINT `problems_ibfk_1` FOREIGN KEY (`PatientID`) REFERENCES `medical_records` (`PatientID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `problems`
--
LOCK TABLES `problems` WRITE;
/*!40000 ALTER TABLE `problems` DISABLE KEYS */;
/*!40000 ALTER TABLE `problems` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `signature`
--
DROP TABLE IF EXISTS `signature`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `signature` (
`id` int NOT NULL AUTO_INCREMENT,
`patientId` int DEFAULT NULL,
`record` enum('NAME_SURNAME','PERSONAL_DATA','PROBLEMS','MEDICATIONS','HEALTH_HISTORY','ALLERGIES','VISITS_HISTORY','LAB_RESULTS') NOT NULL,
`record_pk` int DEFAULT NULL,
`signerId` int NOT NULL,
`signature` blob NOT NULL,
PRIMARY KEY (`id`),
KEY `signerId` (`signerId`),
KEY `patientId` (`patientId`),
CONSTRAINT `signature_ibfk_1` FOREIGN KEY (`signerId`) REFERENCES `users` (`CustomerId`),
CONSTRAINT `signature_ibfk_2` FOREIGN KEY (`patientId`) REFERENCES `medical_records` (`PatientID`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 ;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `signature`
--
LOCK TABLES `signature` WRITE;
/*!40000 ALTER TABLE `signature` DISABLE KEYS */;
/*!40000 ALTER TABLE `signature` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `users`
--
DROP TABLE IF EXISTS `users`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `users` (
`CustomerId` int NOT NULL AUTO_INCREMENT,
`Username` varchar(50) NOT NULL,
`Password` tinyblob,
`Role` enum('LAB_EMPLOYEE','DOCTOR','NURSE','PATIENT_SERVICES_ASSISTANT','CLINICAL_ASSISTANT','PORTER_VOLUNTEER','WARD_CLERK','ADMIN') NOT NULL,
PRIMARY KEY (`CustomerId`),
UNIQUE KEY `AK1_Customer_CustomerName` (`Username`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 ;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `users`
--
LOCK TABLES `users` WRITE;
/*!40000 ALTER TABLE `users` DISABLE KEYS */;
/*!40000 ALTER TABLE `users` 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 2022-01-27 13:12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment