Вы находитесь на странице: 1из 2

create database Hospital

use hospital

create table EMP


(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)

alter table sala


add constraint FK_sala foreign key(Hospital_Cod) references Hospital(hospital_cod)

alter table Doctor


add constraint FK_Doctor foreign key(Hospital_Cod) references Hospital(hospital_cod)

alter table Plantilla


add constraint FK_Plantilla foreign key(Hospital_Cod) references
Hospital(hospital_cod)

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)

Вам также может понравиться

  • Script Du TP
    Script Du TP
    Документ6 страниц
    Script Du TP
    ndembimarvinmarion
    Оценок пока нет
  • Mongo DB
    Mongo DB
    Документ194 страницы
    Mongo DB
    vikash
    Оценок пока нет
  • SQL Practicals Cs
    SQL Practicals Cs
    Документ5 страниц
    SQL Practicals Cs
    Rishabh Garg
    Оценок пока нет
  • Almendras Olivo Bryan Gerardo
    Almendras Olivo Bryan Gerardo
    Документ2 страницы
    Almendras Olivo Bryan Gerardo
    Bryan Almendras Olivo
    Оценок пока нет
  • SQL Script
    SQL Script
    Документ2 страницы
    SQL Script
    alouanihatim3
    Оценок пока нет
  • 00 02
    00 02
    Документ6 страниц
    00 02
    diksha
    Оценок пока нет
  • Emp & Dept Table Creation
    Emp & Dept Table Creation
    Документ3 страницы
    Emp & Dept Table Creation
    Darshan
    Оценок пока нет
  • BD Ventas
    BD Ventas
    Документ173 страницы
    BD Ventas
    JuanEdizonCarbajalDelaCruz
    Оценок пока нет
  • Practice
    Practice
    Документ29 страниц
    Practice
    Sunil B R Sunilshetty
    Оценок пока нет
  • Tysql24 Data
    Tysql24 Data
    Документ6 страниц
    Tysql24 Data
    souravdey3
    Оценок пока нет
  • SQL Company
    SQL Company
    Документ4 страницы
    SQL Company
    eric_76
    Оценок пока нет
  • BD Obl Completa
    BD Obl Completa
    Документ9 страниц
    BD Obl Completa
    Lizbeth Santibañez Cruz
    Оценок пока нет
  • Modern Database Management Textbook
    Modern Database Management Textbook
    Документ5 страниц
    Modern Database Management Textbook
    Keerthana Mahendar
    100% (1)
  • Create Database Quanlysinhvien
    Create Database Quanlysinhvien
    Документ7 страниц
    Create Database Quanlysinhvien
    om ai
    Оценок пока нет
  • BD Empresa
    BD Empresa
    Документ3 страницы
    BD Empresa
    Floyd Legall
    Оценок пока нет
  • Tugas - Manajemen Basis Data - Elmi Tiodata - 210403010022
    Tugas - Manajemen Basis Data - Elmi Tiodata - 210403010022
    Документ2 страницы
    Tugas - Manajemen Basis Data - Elmi Tiodata - 210403010022
    Elmi tiodatacp
    Оценок пока нет
  • DBMS SQL Assignment 4
    DBMS SQL Assignment 4
    Документ6 страниц
    DBMS SQL Assignment 4
    Nagaraj
    Оценок пока нет
  • System - Out.Println (Removestring (STR, 7) ) Return S.Substring (0, Pos) + S.Substring (Pos + 1)
    System - Out.Println (Removestring (STR, 7) ) Return S.Substring (0, Pos) + S.Substring (Pos + 1)
    Документ11 страниц
    System - Out.Println (Removestring (STR, 7) ) Return S.Substring (0, Pos) + S.Substring (Pos + 1)
    Mochamad Lutfy
    Оценок пока нет
  • Baigiai Trigger
    Baigiai Trigger
    Документ17 страниц
    Baigiai Trigger
    truongan_bta
    Оценок пока нет
  • 20 SQL Exercises For Practice: Table Structure and Schema
    20 SQL Exercises For Practice: Table Structure and Schema
    Документ12 страниц
    20 SQL Exercises For Practice: Table Structure and Schema
    Chaitanya IT Returns
    Оценок пока нет
  • DB - Id: IS NOT Null
    DB - Id: IS NOT Null
    Документ5 страниц
    DB - Id: IS NOT Null
    Luis Cutipa
    Оценок пока нет
  • TDSQL
    TDSQL
    Документ5 страниц
    TDSQL
    tgowri
    Оценок пока нет
  • DBMS Da Lab 2
    DBMS Da Lab 2
    Документ56 страниц
    DBMS Da Lab 2
    UPANSHU DAS 19BCI0129
    Оценок пока нет
  • Oracle Assignment 2019: Grade NUMBER, Losal NUMBER, Hisal NUMBER
    Oracle Assignment 2019: Grade NUMBER, Losal NUMBER, Hisal NUMBER
    Документ8 страниц
    Oracle Assignment 2019: Grade NUMBER, Losal NUMBER, Hisal NUMBER
    amit kumarsp
    Оценок пока нет
  • SQL Scripts
    SQL Scripts
    Документ3 страницы
    SQL Scripts
    rathodshri
    Оценок пока нет
  • Database SQL
    Database SQL
    Документ36 страниц
    Database SQL
    thanhit8088
    Оценок пока нет
  • DBMS & Gui Lab Manual
    DBMS & Gui Lab Manual
    Документ15 страниц
    DBMS & Gui Lab Manual
    Gayathri Muniappan
    Оценок пока нет
  • Emp-Dept With Joins
    Emp-Dept With Joins
    Документ5 страниц
    Emp-Dept With Joins
    Mohan Kumar
    Оценок пока нет
  • 22222222
    22222222
    Документ5 страниц
    22222222
    Daniel Bautista Ventura
    Оценок пока нет
  • Company Schema
    Company Schema
    Документ2 страницы
    Company Schema
    Hamza Maher
    Оценок пока нет
  • Anexe: Comenzi SQL
    Anexe: Comenzi SQL
    Документ2 страницы
    Anexe: Comenzi SQL
    simon362003
    Оценок пока нет
  • Table EMP
    Table EMP
    Документ1 страница
    Table EMP
    TTHUNDERBOLTT
    Оценок пока нет
  • BD Employes
    BD Employes
    Документ2 страницы
    BD Employes
    bilalzahid1969
    Оценок пока нет
  • E 5
    E 5
    Документ2 страницы
    E 5
    Amagana Sagara
    Оценок пока нет
  • RDBMS Lab3
    RDBMS Lab3
    Документ7 страниц
    RDBMS Lab3
    Souradeep Gupta
    Оценок пока нет
  • BD Ventas
    BD Ventas
    Документ8 страниц
    BD Ventas
    Tania
    Оценок пока нет
  • Aaa
    Aaa
    Документ2 страницы
    Aaa
    Andri Maulana
    Оценок пока нет
  • IT244 LabWeek 10
    IT244 LabWeek 10
    Документ5 страниц
    IT244 LabWeek 10
    Waleed Omar
    Оценок пока нет
  • Employees
    Employees
    Документ7 страниц
    Employees
    TTHUNDERBOLTT
    Оценок пока нет
  • Ejercicios SQL Sobre La BD de Empleados: Script
    Ejercicios SQL Sobre La BD de Empleados: Script
    Документ2 страницы
    Ejercicios SQL Sobre La BD de Empleados: Script
    Victor Perez
    Оценок пока нет
  • DBMS Lab (18IS507) Manual With Solutions-1
    DBMS Lab (18IS507) Manual With Solutions-1
    Документ24 страницы
    DBMS Lab (18IS507) Manual With Solutions-1
    lokotwiststudio2
    Оценок пока нет
  • Data Staging Northwind
    Data Staging Northwind
    Документ4 страницы
    Data Staging Northwind
    Subandi Wahyudi
    100% (1)
  • Assignment 4
    Assignment 4
    Документ4 страницы
    Assignment 4
    ammar jamal
    Оценок пока нет
  • INF313 - Class Exercise
    INF313 - Class Exercise
    Документ4 страницы
    INF313 - Class Exercise
    nelsonjoshuathomas11
    Оценок пока нет
  • labIT244 Week9
    labIT244 Week9
    Документ5 страниц
    labIT244 Week9
    Waleed Omar
    Оценок пока нет
  • Note tp3
    Note tp3
    Документ5 страниц
    Note tp3
    Amagana Sagara
    Оценок пока нет
  • 10-11-2022 Class Practice
    10-11-2022 Class Practice
    Документ2 страницы
    10-11-2022 Class Practice
    Red ranger
    Оценок пока нет
  • SQL
    SQL
    Документ12 страниц
    SQL
    tej
    Оценок пока нет
  • A. Create EMP Table Using Data Definition Language (DDL) - (Hint: Include Constraints) (14 Marks)
    A. Create EMP Table Using Data Definition Language (DDL) - (Hint: Include Constraints) (14 Marks)
    Документ3 страницы
    A. Create EMP Table Using Data Definition Language (DDL) - (Hint: Include Constraints) (14 Marks)
    Raj Maharjan
    Оценок пока нет
  • M9 Activity
    M9 Activity
    Документ2 страницы
    M9 Activity
    nathalieboco02
    Оценок пока нет
  • TAREA 7 Querys
    TAREA 7 Querys
    Документ2 страницы
    TAREA 7 Querys
    KARINA MICHELLE VILLANUEVA TIRADO
    Оценок пока нет
  • Script 643
    Script 643
    Документ271 страница
    Script 643
    Muhammad Mumshad Hassan
    Оценок пока нет
  • DB
    DB
    Документ1 страница
    DB
    hina
    Оценок пока нет
  • Demo
    Demo
    Документ1 страница
    Demo
    meghashree12r
    Оценок пока нет
  • DBMS Main File Dheeraj
    DBMS Main File Dheeraj
    Документ32 страницы
    DBMS Main File Dheeraj
    biwor
    100% (1)
  • Dbms Assignment 21
    Dbms Assignment 21
    Документ7 страниц
    Dbms Assignment 21
    Shayesta Tabassum
    Оценок пока нет
  • 4) Populate The DEPARTMENT Table
    4) Populate The DEPARTMENT Table
    Документ2 страницы
    4) Populate The DEPARTMENT Table
    Anonymous fdRurgVlB
    Оценок пока нет
  • Profound Python Data Science
    Profound Python Data Science
    От Everand
    Profound Python Data Science
    Оценок пока нет
  • Dianne Auld's Excel Tips: Featuring Compensation and Benefits Formulas Third Edition
    Dianne Auld's Excel Tips: Featuring Compensation and Benefits Formulas Third Edition
    От Everand
    Dianne Auld's Excel Tips: Featuring Compensation and Benefits Formulas Third Edition
    Оценок пока нет
  • SQL Queries: 200+ Queries to Challenge you.
    SQL Queries: 200+ Queries to Challenge you.
    От Everand
    SQL Queries: 200+ Queries to Challenge you.
    Рейтинг: 5 из 5 звезд
    5/5 (2)
  • Clase XML Jueves
    Clase XML Jueves
    Документ2 страницы
    Clase XML Jueves
    Edwards Leon Paredes
    Оценок пока нет
  • Adverbs of Frequency
    Adverbs of Frequency
    Документ4 страницы
    Adverbs of Frequency
    Edwards Leon Paredes
    Оценок пока нет
  • Serial Office
    Serial Office
    Документ1 страница
    Serial Office
    Edwards Leon Paredes
    Оценок пока нет
  • Create Database Hospital
    Create Database Hospital
    Документ2 страницы
    Create Database Hospital
    Edwards Leon Paredes
    Оценок пока нет
  • Create Database Hospital
    Create Database Hospital
    Документ2 страницы
    Create Database Hospital
    Edwards Leon Paredes
    Оценок пока нет