Created
July 2, 2019 04:01
-
-
Save user0able/a29393dad864f98a084bc3d6a15f501c to your computer and use it in GitHub Desktop.
algo .sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* SQLEditor (SQLServer)*/ | |
CREATE TABLE Cargo | |
( | |
id_cargo INT NOT NULL, | |
nombres_cargo VARCHAR(50) NOT NULL, | |
CONSTRAINT Cargo_pkey PRIMARY KEY (id_cargo) | |
); | |
CREATE TABLE Especialidad | |
( | |
id_especialidad INT NOT NULL, | |
nombre_especialidad VARCHAR(50) NOT NULL, | |
CONSTRAINT Especialidad_pkey PRIMARY KEY (id_especialidad) | |
); | |
CREATE TABLE DetalleInforme | |
( | |
id_detalle INT NOT NULL, | |
id_informe INT NOT NULL, | |
observacion_usuario VARCHAR(50) NOT NULL, | |
fecha_registro DATE NOT NULL, | |
CONSTRAINT DetalleInforme_pkey PRIMARY KEY (id_detalle) | |
); | |
CREATE TABLE Stackeholder | |
( | |
rut_stackeholder VARCHAR(13) NOT NULL, | |
nombres_tackeholder VARCHAR(50) NOT NULL, | |
apellidos_stackeholder VARCHAR(50) NOT NULL, | |
fecha_nacimiento DATE NOT NULL, | |
telefono_stackeholder VARCHAR(50) NOT NULL, | |
direccion_stackeholder VARCHAR(50) NOT NULL, | |
mail_stackeholder VARCHAR(50) NOT NULL, | |
id_cargo INT NOT NULL, | |
CONSTRAINT Stackeholder_pkey PRIMARY KEY (rut_stackeholder) | |
); | |
CREATE TABLE Especialista | |
( | |
id_especialista INT NOT NULL, | |
id_especialidad INT NOT NULL, | |
rut_stackeholder VARCHAR(13) NOT NULL, | |
CONSTRAINT Especialista_pkey PRIMARY KEY (id_especialista) | |
); | |
CREATE TABLE Login | |
( | |
rut_stackeholder VARCHAR(13) NOT NULL, | |
password VARCHAR(50) NOT NULL, | |
CONSTRAINT Login_pkey PRIMARY KEY (rut_stackeholder) | |
); | |
CREATE TABLE Usuario | |
( | |
rut_usuario VARCHAR(13) NOT NULL, | |
nombres_usuarios VARCHAR(50) NOT NULL, | |
apellidos_usuario VARCHAR(50) NOT NULL, | |
derivacion_usuario VARCHAR(50) NOT NULL, | |
fecha_nacimiento DATE, | |
telefono_usuario INT, | |
direccion_usuario VARCHAR(50) NOT NULL, | |
mail_usuario VARCHAR(50), | |
CONSTRAINT Usuario_pkey PRIMARY KEY (rut_usuario) | |
); | |
CREATE TABLE Examen | |
( | |
id_examen INT NOT NULL, | |
rut_usuario VARCHAR(13) NOT NULL, | |
rut_stackeholder VARCHAR(13) NOT NULL, | |
detalle_examen VARCHAR(100) NOT NULL, | |
fechaHora_examen DATETIME NOT NULL, | |
CONSTRAINT Examen_pkey PRIMARY KEY (id_examen) | |
); | |
CREATE TABLE Agenda | |
( | |
id_agenda INT NOT NULL, | |
rut_usuario VARCHAR(13) NOT NULL, | |
rut_stackeholder VARCHAR(13) NOT NULL, | |
hora_agenda DATETIME NOT NULL, | |
confirmado BIT NOT NULL | |
); | |
CREATE TABLE Informe | |
( | |
id_informe INT NOT NULL, | |
rut_usuario VARCHAR(13) NOT NULL, | |
rut_stackeholder VARCHAR(13) NOT NULL, | |
diagnostico_usuario INT NOT NULL, | |
fecha_registro DATE NOT NULL, | |
CONSTRAINT Informe_pkey PRIMARY KEY (id_informe) | |
); | |
ALTER TABLE DetalleInforme ADD FOREIGN KEY (id_informe) REFERENCES Informe (id_informe); | |
ALTER TABLE Stackeholder ADD FOREIGN KEY (id_cargo) REFERENCES Cargo (id_cargo); | |
ALTER TABLE Especialista ADD FOREIGN KEY (id_especialidad) REFERENCES Especialidad (id_especialidad); | |
ALTER TABLE Especialista ADD FOREIGN KEY (rut_stackeholder) REFERENCES Stackeholder (rut_stackeholder); | |
ALTER TABLE Login ADD FOREIGN KEY (rut_stackeholder) REFERENCES Stackeholder (rut_stackeholder); | |
ALTER TABLE Examen ADD FOREIGN KEY (rut_usuario) REFERENCES Usuario (rut_usuario); | |
ALTER TABLE Examen ADD FOREIGN KEY (rut_stackeholder) REFERENCES Stackeholder (rut_stackeholder); | |
ALTER TABLE Agenda ADD FOREIGN KEY (rut_usuario) REFERENCES Usuario (rut_usuario); | |
ALTER TABLE Agenda ADD FOREIGN KEY (rut_stackeholder) REFERENCES Stackeholder (rut_stackeholder); | |
ALTER TABLE Informe ADD FOREIGN KEY (rut_usuario) REFERENCES Usuario (rut_usuario); | |
ALTER TABLE Informe ADD FOREIGN KEY (rut_stackeholder) REFERENCES Stackeholder (rut_stackeholder); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment