0% found this document useful (0 votes)
62 views

Create Database Asomuisca

The document contains SQL statements to create database tables for a cattle management system. Tables are created for documents, roles, users, farms, pastures, cattle, births, weaning periods, and other cattle related data. The document also includes sample data inserted into the tables.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
62 views

Create Database Asomuisca

The document contains SQL statements to create database tables for a cattle management system. Tables are created for documents, roles, users, farms, pastures, cattle, births, weaning periods, and other cattle related data. The document also includes sample data inserted into the tables.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

create database asomuisca;

use asomuisca;

insert into documento values (02,'Cedula de extrangeria');

alter table documento


alter column tipo_doc VARCHAR (25) not null

select * from documento;

1 Cedula de ciudadanía
2 Cedula de extrangeria
3 Pasaporte
4 Registro Civil

----------------____-----____----_--_--_----_--__-_--_-__-_--_-_-_--_--_--_--_-_--_-_--__-_--_-__-
_----

use nueva2;
create table documento(
id_doc char not null primary key,
tipo_doc varchar(25) not null
)

create table rol(


id_rol char not null primary key,
nomb_rol varchar(13) not null
)

create table raza(


id_raz varchar(2) not null primary key,
nomb_raz varchar(13) not null
)

create table usuario(


cc_usu varchar(11) not null primary key,
nom1_usu varchar(15) not null,
nom2_usu varchar(15) not null,
ape1_usu varchar(15) not null,
ape2_usu varchar(15) not null,
emai_usu varchar(35) not null,
id_doc char not null,
id_rol char not null,
foreign key(id_doc) references documento(id_doc),
foreign key(id_rol) references rol(id_rol)
)

create table telefono(


num_tel varchar(10) not null,
cc_usu varchar(11) not null,
primary key(num_tel,cc_usu),
foreign key(cc_usu) references usuario(cc_usu)
)

create table finca(


matr_fnc varchar(12) not null primary key,
nomb_fnc varchar(15) not null,
ubic_fnc varchar(50) not null,
medi_fnc int not null,
cc_usu varchar(11) not null,
foreign key(cc_usu) references usuario(cc_usu)
)

create table pasto(


id_pst varchar(2) not null primary key,
tipo_pst varchar(13) not null,
)

create table potrero(


id_ptr varchar(2) not null,
medi_ptr int not null,
id_pst varchar(2) not null,
matr_fnc varchar(12) not null,
primary key(id_ptr,matr_fnc),
foreign key (matr_fnc) references finca(matr_fnc),
foreign key (id_pst) references pasto(id_pst)
)

create table genero(


codi_gen char not null primary key,
nomb_gen varchar(6) not null
)

create table ganado(


id_gan varchar(10) not null primary key,
fchN_gan datetime not null,
peso_gan int not null,
mdre_gan varchar(10) not null,
pdre_gan varchar(10) not null,
id_raz varchar (2) not null,
codi_gen char not null,
foreign key(id_raz) references raza(id_raz),
foreign key(codi_gen) references genero(codi_gen)
)

create table parto(


fcha_pto datetime not null,
id_gan varchar(10) not null,
primary key(fcha_pto,id_gan),
foreign key(id_gan) references ganado(id_gan)
)

create table tercio(


id_trc char not null primary key,
nomb_fse varchar(13) not null
)

create table ganado_tercio(


id_gan varchar(10) not null,
id_trc char not null,
fcha_gtr datetime not null,
primary key(id_gan,id_trc,fcha_gtr),
foreign key(id_gan) references ganado(id_gan),
foreign key(id_trc) references tercio(id_trc)
)

create table ganado_potrero(


id_gan varchar(10) not null,
id_ptr varchar(2) not null,
matr_fnc varchar(12) not null,
fcha_ptr datetime not null,
primary key(id_gan,id_ptr,matr_fnc,fcha_ptr),
foreign key(id_ptr,matr_fnc) references potrero(id_ptr,matr_fnc),
foreign key(id_gan) references ganado(id_gan)
)

create table produccion(


fcha_prd datetime not null,
id_gan varchar(10) not null,
ltrs int not null,
primary key(fcha_prd,id_gan),
foreign key(id_gan) references ganado(id_gan)
)

create table fertilidad(


id_frt char not null primary key,
nomb_frt varchar(12) not null
)

create table ganado_fertilidad(


id_gan varchar(10) not null,
id_frt char not null,
fcha_gfr datetime not null
primary key(id_gan,id_frt),
foreign key(id_gan) references ganado(id_gan),
foreign key(id_frt) references fertilidad(id_frt)
)

create table enfermedad(


codi_nfm char not null primary key,
nomb_nfm varchar(20) not null
)

create table medicamento(


codi_mdc varchar(3) not null primary key,
nomb_mdc varchar(15) not null
)

create table ganado_enfermedad(


codi_nfm char not null,
id_gan varchar(10) not null,
fcha_nfm datetime not null,
desc_nfm varchar(200) not null,
primary key(codi_nfm,id_gan),
foreign key(id_gan) references ganado(id_gan),
foreign key(codi_nfm) references enfermedad(codi_nfm)
)

create table ganado_medicamento(


id_gan varchar(10) not null,
codi_mdc varchar(3) not null,
fcha_mdc datetime not null,
primary key(codi_mdc,id_gan),
foreign key(id_gan) references ganado(id_gan),
foreign key(codi_mdc) references medicamento(codi_mdc)
)

-------------------------__-___--___________-__-__--__-_--________---_-__-__-__--_----_-----_-

INSERT into documento values (01,'Cedula de ciudadania')


INSERT into documento values (02,'Cedula de extrangeria')
INSERT into documento values (03,'Pasaporte')

INSERT into rol values (01,'Administrador')


INSERT into rol values (02,'Asociado')
INSERT into rol values (03,'Auxiliar')

INSERT into usuario values (1069959670,'Juan','Daniel','Ortiz','Ceballos','[email protected]',1,1)


INSERT into usuario values (1069854375,'Edwin','Smit','Patiño','Lara','[email protected]',1,2)
INSERT into usuario values (1069872376,'Eliana','Andrea','Herrera','Lievano','[email protected]',1,3)

INSERT into telefono values (3047310377,1069854375)


INSERT into telefono values (3047468392,1069872376)
INSERT into telefono values (3217489374,1069959670)

INSERT into finca values (1234567890,'la maria','7km de la escuala cucharal', 1000, 1069872376)
INSERT into finca values (0987654321,'la maria','7km de la escuala cucharal', 1000, 1069872376)

You might also like