Base de datos farmacia en sql

Páginas: 9 (2086 palabras) Publicado: 9 de junio de 2010
use master
go
drop database bdFarmacia
go
create database bdFarmacia
go
use bdFarmacia
go
/*CREAR TIPOS DE DATOS*/
EXEC sp_addtype textoLargo, 'VARCHAR(85)'
EXEC sp_addtype textoMedio, 'VARCHAR(50)'
EXEC sp_addtype textoCorto, 'VARCHAR(15)'
EXEC sp_addtype textoCodigo, 'CHAR(6)'
go
/*CREACION DE TABLAS*/
create table tblEmpleado
(
idEmpleado textoCodigo primary key,
dnitextoCorto,use master
go
drop database bdFarmacia
go
create database bdFarmacia
go
use bdFarmacia
go
/*CREAR TIPOS DE DATOS*/
EXEC sp_addtype textoLargo, 'VARCHAR(85)'
EXEC sp_addtype textoMedio, 'VARCHAR(50)'
EXEC sp_addtype textoCorto, 'VARCHAR(15)'
EXEC sp_addtype textoCodigo, 'CHAR(6)'
go
/*CREACION DE TABLAS*/
create table tblEmpleado
(
idEmpleado textoCodigo primary key,
dnitextoCorto,
nombre textoLargo,
direccion textoLargo,
telefono textoCorto
)

create table tblIngrediente
(
idIngrediente textoCodigo primary key,
nombre textoLargo,
caracteriztica textoLargo
)

create table tblAccionTerapeutica
(
idAccionTerapeutica textoCodigo primary key,
denominacion textoCorto
)

create table tblLaboratorio
(
idLaboratorio textoCodigo primary key,nombre textoLargo,
telefono textoCorto
)

/*CREAR TABLAS CON RELACIONES*/
create table tblVenta
(
idVenta textoCodigo primary key,
cantidad int,
precio decimal(10,2),
fecha datetime,
idEmpleado textoCodigo foreign key (idEmpleado) references tblEmpleado
)
create table tblMedicamento
(
idMedicamento textoCodigo primary key,
nombre textoLargo,
prospecto textoLargo,idLaboratorio textoCodigo foreign key (idLaboratorio) references tblLaboratorio
)
create table tblPresentacion
(
idPresentacion textoCodigo primary key,
stock int,
precio decimal(10,2),
detalle textoMedio,
idMedicamento textoCodigo foreign key (idMedicamento) references tblMedicamento
)
create table tblMedicamentoIngrediente
(
idIngrediente textoCodigo foreign key (idIngrediente)references tblIngrediente,
idMedicamento textoCodigo foreign key (idMedicamento) references tblMedicamento
)
create table tblAccionMedicamento
(
idMedicamento textoCodigo foreign key (idMedicamento) references tblMedicamento,
idAccionTerapeutica textoCodigo foreign key (idAccionTerapeutica)references tblAccionTerapeutica
)
create table tblVentaPresentacion
(
idVenta textoCodigo foreignkey (idVenta) references tblVenta,
idPresentacion textoCodigo foreign key (idPresentacion) references tblPresentacion
)
go
/*INGRESO DE DATOS*/
insert into tblIngrediente
values('I00001','Apicilina','330mg')
insert into tblIngrediente
values('I00002','Sulbactam','130mg')
insert into tblIngrediente
values('I00003','Amoxicilina','750mg')
insert into tblIngredientevalues('I00004','Acido clavulanico','250mg')
insert into tblIngrediente
values('I00005','Paracetamol','500mg')
insert into tblIngrediente
values('I00006','Clorfenamina','10mg')
insert into tblIngrediente
values('I00007','Alprazolan','2mg')
insert into tblIngrediente
values('I00008','Exipientes CSF','')
insert into tblIngrediente
values('I00009','Metamizol','250mg')
insert into tblIngredientevalues('I00010','Amikacina','1g')
insert into tblIngrediente
values('I00011','Dexametazona','4mg')
insert into tblIngrediente
values('I00012','Albendazol','100mg')
insert into tblIngrediente
values('I00013','Praziquantel','20mg')
insert into tblIngrediente
values('I00014','Latex','')
go
insert into tblLaboratorio
values('L00001','ACME','999999')
insert into tblLaboratoriovalues('L00002','ROCHE','333333')
insert into tblLaboratorio
values('L00003','BAYER','444444')
insert into tblLaboratorio
values('L00004','FARMINDUSTRIA','888888')
insert into tblLaboratorio
values('L00005','EL HUECO','555555')
go
insert into tblMedicamento
values('M00001','Unasyn','Nombre comercial','L00001')
insert into tblMedicamento
values('M00002','Clavumox','Nombre comercial','L00001')...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • Bases de datos, no sql y sql
  • Base De Datos Sql
  • Ejercicio de bases de datos en sql
  • Base De Datos Sql
  • base de datos sql
  • sql base de datos
  • Bases De Datos Sql
  • Consulta a la base de datos SQL

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS