forked from mestanza/MySQL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpacientesmedicos.sql
85 lines (72 loc) · 3.33 KB
/
pacientesmedicos.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
-- MySQL Script generated by MySQL Workbench
-- 08/22/16 21:38:41
-- Model: New Model Version: 1.0
-- MySQL Workbench Forward Engineering
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
-- -----------------------------------------------------
-- Schema mydb
-- -----------------------------------------------------
DROP SCHEMA IF EXISTS `mydb` ;
-- -----------------------------------------------------
-- Schema mydb
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `mydb` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ;
USE `mydb` ;
-- -----------------------------------------------------
-- Table `mydb`.`paciente`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`paciente` ;
CREATE TABLE IF NOT EXISTS `mydb`.`paciente` (
`id_paciente` VARCHAR(10) NOT NULL COMMENT '',
`nombre` VARCHAR(45) NOT NULL DEFAULT 'Sin nombre' COMMENT '',
`apellidos` VARCHAR(45) NOT NULL DEFAULT 'Sin apellidos' COMMENT '',
`direccion` VARCHAR(45) NOT NULL DEFAULT 'Sin direccion' COMMENT '',
`poblacion` VARCHAR(45) NULL DEFAULT 'Sin poblacion' COMMENT '',
`provincia` VARCHAR(45) NULL DEFAULT 'Sin provincia' COMMENT '',
`CP` VARCHAR(10) NULL COMMENT '',
`telefono` VARCHAR(45) NULL DEFAULT 'Sin telefono' COMMENT '',
`fecha_nacimiento` DATE NOT NULL COMMENT '',
PRIMARY KEY (`id_paciente`) COMMENT '')
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`medico`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`medico` ;
CREATE TABLE IF NOT EXISTS `mydb`.`medico` (
`id_medico` VARCHAR(10) NOT NULL COMMENT '',
`nombre` VARCHAR(45) NOT NULL DEFAULT 'Sin nombre' COMMENT '',
`apellidos` VARCHAR(45) NOT NULL DEFAULT 'Sin apellidos' COMMENT '',
`telefono` VARCHAR(45) NULL DEFAULT 'Sin telefono' COMMENT '',
`especialidad` VARCHAR(45) NOT NULL DEFAULT 'Sin especialidad' COMMENT '',
PRIMARY KEY (`id_medico`) COMMENT '')
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`ingreso`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`ingreso` ;
CREATE TABLE IF NOT EXISTS `mydb`.`ingreso` (
`id_ingreso` INT NOT NULL AUTO_INCREMENT COMMENT '',
`fecha_ingreso` DATE NOT NULL COMMENT '',
`habitacion` VARCHAR(45) NOT NULL COMMENT '',
`cama` VARCHAR(45) NOT NULL COMMENT '',
`paciente_id_paciente` VARCHAR(10) NOT NULL COMMENT '',
`medico_id_medico` VARCHAR(10) NOT NULL COMMENT '',
PRIMARY KEY (`id_ingreso`, `paciente_id_paciente`, `medico_id_medico`) COMMENT '',
INDEX `fk_ingreso_paciente_idx` (`paciente_id_paciente` ASC) COMMENT '',
INDEX `fk_ingreso_medico1_idx` (`medico_id_medico` ASC) COMMENT '',
CONSTRAINT `fk_ingreso_paciente`
FOREIGN KEY (`paciente_id_paciente`)
REFERENCES `mydb`.`paciente` (`id_paciente`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_ingreso_medico1`
FOREIGN KEY (`medico_id_medico`)
REFERENCES `mydb`.`medico` (`id_medico`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;