The document creates several tables in a Hospital database - EMP for employees, DEPT for departments, HOSPITAL for hospitals, DOCTOR, PLANTILLA, and SALA. It defines primary and foreign keys between the tables, inserts sample data, and creates relationships between the tables.
The document creates several tables in a Hospital database - EMP for employees, DEPT for departments, HOSPITAL for hospitals, DOCTOR, PLANTILLA, and SALA. It defines primary and foreign keys between the tables, inserts sample data, and creates relationships between the tables.
The document creates several tables in a Hospital database - EMP for employees, DEPT for departments, HOSPITAL for hospitals, DOCTOR, PLANTILLA, and SALA. It defines primary and foreign keys between the tables, inserts sample data, and creates relationships between the tables.
(EMP_NRO int not null, Apellido nvarchar(50) not null, Oficio nvarchar(50) not null, Dir int not null, Fecha_Alt smalldatetime not null, Salario int not null, Comision int not null, Dept_Nro int not null ) alter table EMP add primary key(EMP_NRO)
create table DEPT
(Dept_Nro int primary key not null, DNombre nvarchar(50) not null, Loc nvarchar(50) not null)
create table Hospital
(Hospital_Cod int primary key not null, Nombre nvarchar(50) not null, Direccion nvarchar(50) not null, Telefono nvarchar(50) not null, Num_Cama int not null)
create table Doctor
(Hospital_Cod int not null, Doctor_Nro int primary key not null, Apellido nvarchar(50) not null, Especialidad nvarchar(50)not null)
create table Plantilla
(Hospital_Cod int not null, Sala_Cod int not null, Empleado_Nro int not null, Apellido nvarchar(50) not null, Funcion nvarchar(50) not null, T nvarchar(50) not null, Salario int not null)
create table Sala
(Hospiatl_Cod int not null, Sala_Cod int not null, Nombre nvarchar(50) not null, Num_Cama int not null)
create table Enfermo
( Inscripcion int not null, Apellido nvarchar(50) not null, Direccion nvarchar(50) not null, Fecha_Nac smalldatetime not null, S nvarchar(50) not null, NSS int not null) alter table EMP add constraint FK_Emp foreign key(Dept_Nro) references Dept(Dept_Nro)
insert into Emp values (7369,'Sanchez','Empleado',7902,1980-12-17,104000,0,20)
insert into Emp values (7499,'Arroyo','Vendedor',7698,1981-02-22,208000,39000,30) insert into Emp values (7521,'Sala','Vendedor',689,1981-02-22,162500,65000,30) insert into Emp values (7566,'Jimenez','Director',7839,1981-04-02,386750,0,20) insert into Emp values (7654,'Martin','Vendedor',7698,1981-09-28,182000,182000,30) insert into Emp values (7698,'Negro','Director',7839,1981-05-01,370500,0,30) insert into Emp values (7782,'Cerezo','Director',7839,1981-06-09,318500,0,10) insert into Emp values (7788,'Nino','Analista',7566,1987-03-30,390000,0,20) insert into Emp values (7839,'Rey','Presidente',0,1981-11-17,650000,0,10) insert into Emp values (7844,'Tovar','Vendedor',7698,1981-09-08,195000,0,30) insert into Emp values (7876,'Alonso','Empleado',7788,1987-05-03,143000,0,20) insert into Emp values (7900,'Jimeno','Empleado',7698,1981-12-03,123500,0,30) insert into Emp values (7902,'Fernandez','Analista',7566,1981-12-03,390000,0,20) insert into Emp values (7900,'Jimeno','Empleado',7698,1981-12-03,123500,0,30) insert into Emp values (7934,'Muoz','Empleado',7782,1982-06-23,169000,0,10) insert into Emp values (7119,'Serra','Director',7839,1983-11-19,225000,39000,20) insert into Emp values (7322,'Garcia','Empleado',7119,1982-10-12,129000,0,20)
insert into Dept values(10,'Contabilidad','Elche')
insert into Dept values(20,'Investigacion','Madrid') insert into Dept values(30,'Ventas','Barcelona') insert into Dept values(40,'Produccion','Salamanca')
insert into Hospital values (19,'Provincial','ODonell 50',964-4256,502)
insert into Hospital values (18,'General','Atocha s/n',595-3111,987) insert into Hospital values (22,'La Paz','Castellana 100',923-5411,412) insert into Hospital values (45,'San Carlos','Ciudad Universitaria',597-1500,845)