Parcial Base de Datos

También podría gustarte

Está en la página 1de 1

CREATE DATABASE PARCIAL;

USE PARCIAL;

CREATE TABLE ACCIDENTE (NroAcc varchar(10) not null, FechaAccidente Date not null,
Lugar varchar(20) not null, NroVictimas integer null, PRIMARY KEY (NroAcc));

CREATE TABLE VICTIMAS (Identificador varchar(15) not null, Nombre varchar(60) not
null, Apellido varchar(60) not null, Telefono varchar(15) null, PRIMARY KEY
(Identificador));

CREATE TABLE ACCIDENTES_VICTIMAS (Idvictima varchar(15) not null, NroAccidente


varchar(10) not null, PRIMARY KEY (Idvictima, NroAccidente));

ALTER TABLE ACCIDENTES_VICTIMAS ADD FOREIGN KEY (Idvictima) REFERENCES VICTIMAS


(Identificador);
ALTER TABLE ACCIDENTES_VICTIMAS ADD FOREIGN KEY (NroAccidente) REFERENCES ACCIDENTE
(NroAcc);

INSERT INTO ACCIDENTE (NroAcc,FechaAccidente,Lugar,NroVictimas) VALUES


('001','2019-02-20','CLL 38','1');
INSERT INTO ACCIDENTE (NroAcc,FechaAccidente,Lugar,NroVictimas) VALUES
('020','2019-04-02','Ave circunvalar',null);

INSERT INTO VICTIMAS (Identificador,Nombre,Apellido,Telefono) VALUES


('7723467','Maria','Lopez','7820852');
INSERT INTO VICTIMAS (Identificador,Nombre,Apellido,Telefono) VALUES
('9876542','Luis','Martinez',null);

UPDATE VICTIMA SET Telefono = 7816789 WHERE Identificador=9876542;

DELETE FROM ACCIDENTE WHERE NroAcc=020;

También podría gustarte