hola ...
tengo la siguiente BD... la cosa es que al buscar por nombre de articulo se me disparan la cantidad de resultados... se asocian valores que no deberian... quien me puede ayudar en realizar la consulta sobre un nombre de articulo, donde:
dado un nombre de articulo se despliegue info empresa, pais, cliente... todo y obviamnete los valores respectivos de ese articulo
Código:
/*==============================================================*/
/* DBMS name: MySQL 5.0 */
/* Created on: 21/02/2008 9:59:55 */
/*==============================================================*/
drop table if exists ARTICULO;
drop table if exists CLIENTE;
drop table if exists DETALLE;
drop table if exists EMPRESA;
drop table if exists FORMULARIO;
drop table if exists PAIS;
drop table if exists VALORES_ARTICULO;
drop table if exists VALOR_ARTICULO;
/*==============================================================*/
/* Table: ARTICULO */
/*==============================================================*/
create table ARTICULO
(
ARTICULO_COD varchar(10) not null,
ARTICULO_NOMBRE varchar(30),
ARTICULO_CLASIF text,
primary key (ARTICULO_COD)
);
/*==============================================================*/
/* Table: CLIENTE */
/*==============================================================*/
create table CLIENTE
(
CLIENTE_RUT varchar(10) not null,
CLIENTE_NOMBRE char(50),
CLIENTE_DSC text,
primary key (CLIENTE_RUT)
);
/*==============================================================*/
/* Table: DETALLE */
/*==============================================================*/
create table DETALLE
(
ARTICULO_COD varchar(10) not null,
FORMULARIO_COD varchar(20) not null
);
/*==============================================================*/
/* Table: EMPRESA */
/*==============================================================*/
create table EMPRESA
(
EMPRESA_COD varchar(10) not null,
PAIS_COD int not null,
EMPRESA_NOMBRE varchar(20),
primary key (EMPRESA_COD)
);
/*==============================================================*/
/* Table: FORMULARIO */
/*==============================================================*/
create table FORMULARIO
(
FORMULARIO_COD varchar(20) not null,
CLIENTE_RUT varchar(10) not null,
EMPRESA_COD varchar(10) not null,
primary key (FORMULARIO_COD)
);
/*==============================================================*/
/* Table: PAIS */
/*==============================================================*/
create table PAIS
(
PAIS_COD int not null,
PAIS_NOMBRE varchar(20),
primary key (PAIS_COD)
);
/*==============================================================*/
/* Table: VALORES_ARTICULO */
/*==============================================================*/
create table VALORES_ARTICULO
(
ARTICULO_COD varchar(10) not null,
VALOR_COD int not null
);
/*==============================================================*/
/* Table: VALOR_ARTICULO */
/*==============================================================*/
create table VALOR_ARTICULO
(
ARTICULO_VALOR1 float,
ARTICULO_VALOR2 float,
ARTICULO_VALOR3 float,
VALOR_COD int not null,
primary key (VALOR_COD)
);
alter table DETALLE add constraint FK_RELATIONSHIP_3 foreign key (FORMULARIO_COD)
references FORMULARIO (FORMULARIO_COD) on delete restrict on update restrict;
alter table DETALLE add constraint FK_RELATIONSHIP_4 foreign key (ARTICULO_COD)
references ARTICULO (ARTICULO_COD) on delete restrict on update restrict;
alter table EMPRESA add constraint FK_RELATIONSHIP_6 foreign key (PAIS_COD)
references PAIS (PAIS_COD) on delete restrict on update restrict;
alter table FORMULARIO add constraint FK_RELATIONSHIP_2 foreign key (EMPRESA_COD)
references EMPRESA (EMPRESA_COD) on delete restrict on update restrict;
alter table FORMULARIO add constraint FK_RELATIONSHIP_5 foreign key (CLIENTE_RUT)
references CLIENTE (CLIENTE_RUT) on delete restrict on update restrict;
alter table VALORES_ARTICULO add constraint FK_RELATIONSHIP_7 foreign key (ARTICULO_COD)
references ARTICULO (ARTICULO_COD) on delete restrict on update restrict;
alter table VALORES_ARTICULO add constraint FK_RELATIONSHIP_8 foreign key (VALOR_COD)
references VALOR_ARTICULO (VALOR_COD) on delete restrict on update restrict;
Recuerden dado un nombre de articulo retornar toda la info relacionada con cliente, empresa y valores...
gracias