· 6 years ago · Mar 09, 2019, 05:04 AM
1-- phpMyAdmin SQL Dump
2-- version 4.8.4
3-- https://www.phpmyadmin.net/
4--
5-- Host: 127.0.0.1:3306
6-- Generation Time: 09-Mar-2019 Ã s 04:57
7-- Versão do servidor: 5.7.24
8-- versão do PHP: 7.3.1
9
10SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
11SET AUTOCOMMIT = 0;
12START TRANSACTION;
13SET time_zone = "+00:00";
14
15
16/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
17/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
18/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
19/*!40101 SET NAMES utf8mb4 */;
20
21--
22-- Database: `hospital`
23--
24CREATE DATABASE IF NOT EXISTS `hospital` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
25USE `hospital`;
26
27-- --------------------------------------------------------
28
29--
30-- Estrutura da tabela `appointments`
31--
32
33DROP TABLE IF EXISTS `appointments`;
34CREATE TABLE IF NOT EXISTS `appointments` (
35 `id` int(11) NOT NULL AUTO_INCREMENT,
36 `doctor_id` int(11) NOT NULL,
37 `patient_id` int(11) NOT NULL,
38 `date` date NOT NULL,
39 PRIMARY KEY (`id`),
40 KEY `doctor_id` (`doctor_id`),
41 KEY `patient_id` (`patient_id`)
42) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;
43
44--
45-- Extraindo dados da tabela `appointments`
46--
47
48INSERT INTO `appointments` (`id`, `doctor_id`, `patient_id`, `date`) VALUES
49(1, 1, 1, '2019-03-09'),
50(2, 2, 2, '2019-03-09'),
51(3, 1, 3, '2019-02-08');
52
53-- --------------------------------------------------------
54
55--
56-- Estrutura da tabela `doctors`
57--
58
59DROP TABLE IF EXISTS `doctors`;
60CREATE TABLE IF NOT EXISTS `doctors` (
61 `id` int(11) NOT NULL AUTO_INCREMENT,
62 `name` varchar(255) NOT NULL,
63 `birthday` date NOT NULL,
64 PRIMARY KEY (`id`)
65) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;
66
67--
68-- Extraindo dados da tabela `doctors`
69--
70
71INSERT INTO `doctors` (`id`, `name`, `birthday`) VALUES
72(1, 'Kyo Kusanagi', '1987-09-01'),
73(2, 'Andy Bogard', '1972-08-16');
74
75-- --------------------------------------------------------
76
77--
78-- Estrutura da tabela `examinations`
79--
80
81DROP TABLE IF EXISTS `examinations`;
82CREATE TABLE IF NOT EXISTS `examinations` (
83 `id` int(11) NOT NULL AUTO_INCREMENT,
84 `name` varchar(255) NOT NULL,
85 `appointment_id` int(11) NOT NULL,
86 PRIMARY KEY (`id`),
87 KEY `appointment` (`appointment_id`)
88) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1;
89
90--
91-- Extraindo dados da tabela `examinations`
92--
93
94INSERT INTO `examinations` (`id`, `name`, `appointment_id`) VALUES
95(1, 'Rectal', 1),
96(2, 'Urinalysis ', 1),
97(3, 'Stool test', 1),
98(4, 'Blood teste', 2),
99(5, 'blood test', 3);
100
101-- --------------------------------------------------------
102
103--
104-- Estrutura da tabela `patients`
105--
106
107DROP TABLE IF EXISTS `patients`;
108CREATE TABLE IF NOT EXISTS `patients` (
109 `id` int(11) NOT NULL AUTO_INCREMENT,
110 `name` varchar(255) NOT NULL,
111 `birthday` date NOT NULL,
112 `blood_type` enum('A+','A-','B+','B-','AB+','AB-','O+','O-','') DEFAULT NULL,
113 PRIMARY KEY (`id`)
114) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;
115
116--
117-- Extraindo dados da tabela `patients`
118--
119
120INSERT INTO `patients` (`id`, `name`, `birthday`, `blood_type`) VALUES
121(1, 'Yashiro Nanakase', '1973-12-31', 'O+'),
122(2, 'Chris', '1990-05-03', NULL),
123(3, 'Iori Yagami', '1980-03-25', 'O+');
124
125--
126-- Constraints for dumped tables
127--
128
129--
130-- Limitadores para a tabela `appointments`
131--
132ALTER TABLE `appointments`
133 ADD CONSTRAINT `appointments_ibfk_1` FOREIGN KEY (`doctor_id`) REFERENCES `doctors` (`id`),
134 ADD CONSTRAINT `appointments_ibfk_2` FOREIGN KEY (`patient_id`) REFERENCES `patients` (`id`);
135
136--
137-- Limitadores para a tabela `examinations`
138--
139ALTER TABLE `examinations`
140 ADD CONSTRAINT `examinations_ibfk_1` FOREIGN KEY (`appointment_id`) REFERENCES `appointments` (`id`);
141COMMIT;
142
143/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
144/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
145/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;