Sei sulla pagina 1di 13

AP6-AA1-EV2- CONSTRUIR LA BASE DE DATOS PARA SU PROYECTO DE

FORMACIÓN

ALEXIS CARDOZO LEON

SERVICIO NACIONAL DE APRENDIZAJE SENA

CENTRO DE DISEÑO Y METROLOGIA DISTRITO CAPITAL

ANÁLISIS Y DESARROLLO DE SISTEMAS DE INFORMACIÓN (1310056)

BARRANCABERMEJA
2017
Introducción

1. Sentencias utilizadas en la construcción de los objetos de la base de


datos.
2. Diagrama relacional en el sistema.
3. Pantallazos de la estructura construida.
4. Sentencias de inserción de datos de prueba.
5. Pantallazos con la información almacenada en las tablas.
1. Sentencias utilizadas en la construcción de los objetos de la base de
datos.
Creación base de datos proyecto_de_formacion
Show databases;
Créate database proyecto_de_formacion;
Use proyecto_de_formacion;
Creamos las tablas
Tabla proveedores
CREATE TABLE proveedores (idproveedores int not null, primary key
(idproveedores));
Tabla PRODUCTO_has_PROVEEDORES

CREATE TABLE PRODUCTO_has_PROVEEDORES(


idproveedores int not null,
idproductoint not null,
PRIMARY KEY (idproveedores,idproducto),
FOREIGN KEY (idproveedores) references
proveedores(idproveedores))
La segunda llave foránea la debo agregar después de que cree la
table producto
Tabla producto
CREATE TABLE PRODUCTO(
idproductoint not null,
Propedidoint not null,
ProTipovarchar(20),
ProStockMinimo integer not null,
ProStockactual integer not null,
PRIMARY KEY(idproducto));
alter table PRODUCTO_has_PROVEEDORES add constraint
foreign key (idproducto) REFERENCES PRODUCTO(idproducto);

Creamos la tabla pedidos


CREATE TABLE PEDIDO(
idpedidoint not null,
Pedserviciointnot null,
Pedtipovarchar(20),
idarticulointnot null,
PRIMARY KEY(idpedido));
Agregamos la llave foránea de propedido

Alter table Producto addconstraintforeignkey(Propedido) references


PEDIDO(idpedido);

Creamos la tabla servicios

CREATE TABLE SERVICIOS(


idservicioint not null,
Serclienteintnotnull,Serclinicavarchar(80),Sersalonbellezavarchar(80)
,tienda varchar(45),
PRIMARY KEY(idservicio));

Creamos la llave foranea de pedidos

mysql> alter table PEDIDO add constraint foreign key(Pedservicio)


References servicios(idservicio);

creamostablacliente
CREATE TABLE CLIENTE(Carneclienteint not null,Clitrabajadorint
not null,idclienteint not null,Clidireccion varchar(20),Clidniint not
null,Clitelefonoint not null,Clinombre varchar(80),Cliapellidos
varchar(80),PRIMARY KEY(Carnecliente));
agregamos la llave foránea

mysql> alter table SERVICIOS add constraint foreign key(Sercliente)


references CLIENTE(Carnecliente);
Creamos la tabla reservas

mysql> CREATE TABLE RESERVAS(idreservasint primary key not null


auto_increment,
Resservicioint not null,resfechahora date);

Agregamos la llave foranea

mysql> alter table reservas add constraint foreign key(Resservicio)


references SERVICIOS(idservicio);

creamos la tabla animal


mysql> CREATE TABLE ANIMAL(idanimalint PRIMARY KEY not null
auto_increment,Aniclienteint not null,FOREIGN KEY(Anicliente)
references cliente(Carnecliente));

agregamos la llave foraneaClitrabajador

alter table CLIENTE add constraint foreign key(Clitrabajador) references

TRABAJADOR(idtrabajador);

mysql> alter table CLIENTE add constraint foreign key(Clitrabajador)


references

animal(idanimal);

mysql> CREATE TABLE ANIMAL(idanimalint PRIMARY KEY not null


auto_increment,Aniclienteint not null,FOREIGN KEY(Anicliente) references
cliente(Carnecliente));
creamos la tabla trabajador

mysql> create table TRABAJADOR(idtrabajadorint PRIMARY KEY NOT


NULL,Tradniintnot null,Tradatos varchar(80));

creamos la tabla historial

mysql> Create table HISTORIAL(

idHistorialint not null,

Hisanimalint not null,

Hisfecha date,

Hiscirugiarevisioncuravarchar(100),

PRIMARY KEY(idhistorial));

AÑADIMOS LA LLAVE FORANEA

mysql>alter table HISTORIAL add constraint foreign key(Hisanimal) references


ANIMAL(idanimal);
2.diagrama relacional

2. Pantallazos de la estructura construida


Base de datos:
Table proveedores

Tablas producto_has_proveedores

Table producto

Tablapedido

Tabla SERVICIOS
Tabla reservas

Tabla CLIENTE

TABLA TRABAJADOR

TABLA ANIMAL
TABLA HISTORIAL

3. Sentencias de inserción de datos de prueba


Como no sabia que datos colocar pues me los invente todos;)
Proveedores
mysql> insert into PROVEEDORES (idproveedores)
values('110237994');

Producto_has_proveedores

mysql> INSERT INTO PRODUCTO_HAS_PROVEEDORES


(idproveedores,idproducto) values (1
10237994,12345);

Producto
mysql>insertinto producto
(idproducto,Propedido,Protipo,Prostockminimo,Prostoc
kactual) values(12345,56789,1,11,9);

pedido

mysql>insertinto pedido (idpedido,Pedservicio,Pedtipo,idarticulo)


values (6562
56,2,'urgente',5500);
SERVICIO
mysql>insertinto servicios
(idservicio,Sercliente,Serclinica,Sersalonbelleza,S
ertienda) values (316894,3686,'veterinaria','salon
2','tiendaveterinaria');
RESERVAS
mysql>insertinto reservas (idreservas,Resservicio,Resfechahora)
values (78910,80,'2017-10-11 7:00');

Cliente
mysql>insertinto cliente (Carnecliente,Clitrabajador,idcliente,Clidireccion,Cl

idni,Clitelefono,Clinombre,Cliapellidos) values (123456,130056,123456,'calle


35#

34-12',123456789,6553631,'jose_daniel','solano');

Trabajador

mysql>insertinto trabajador (idtrabajador,Tradni,Tradatos) values (130056,1234

56,'brindar_un_buen_servicio');

ANIMAL

mysql> insert into animal(idanimal,Anicliente) values (0000,123456);

historial

mysql>insertinto historial (idhistorial,Hisanimal,Hisfecha,Hiscirugiarevisionc

ura) values (130056,13,'2017-11-17','cirugia_a_pierna-realizarpuntos-


dar_via_ora

lantibiotioco_cada_dia');

4. Pantallazos con la información almacenada en las tablas


proveedores

Producto_has_proveedores
PRODUCTO

PEDIDO

SERVICIO TABLE
Reservas table

CLIENTE TABLE
Tabla animal

Tabla historial

Potrebbero piacerti anche