Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- create database if not exists lascanarias
- DEFAULT CHARACTER SET utf8
- DEFAULT COLLATE utf8_general_ci;
- SET NAMES utf8;
- use lascanarias;
- create table if not exists sucursal(
- cod int primary key auto_increment,
- localidad varchar(30))ENGINE=InnoDB;
- create table if not exists usuario(
- user varchar(30) primary key,
- pass varchar(64),
- cod_suc int,
- CONSTRAINT Usuario_CodSuc_FK FOREIGN KEY(cod_suc)
- REFERENCES sucursal(cod));
- create table if not exists vendedor(
- cod int primary key auto_increment,
- nombre varchar(30) not null,
- apellido varchar(30) not null,
- cod_suc int not null,
- CONSTRAINT Vendedor_CodSuc_FK FOREIGN KEY(cod_suc)
- REFERENCES sucursal(cod))ENGINE=InnoDB;
- create table if not exists producto(
- descrip varchar(100) primary key,
- precio decimal(6,2));
- create table if not exists transito(
- cod int primary key auto_increment,
- descrip varchar(40))ENGINE=InnoDB;
- create table if not exists marca(
- cod int primary key auto_increment,
- nombre varchar(100))ENGINE=InnoDB;
- create table if not exists calidad(
- descrip varchar(10) primary key);
- create table if not exists medida(
- descrip varchar(9) primary key)ENGINE=InnoDB;
- create table if not exists tipoventa(
- cod int auto_increment primary key,
- descrip varchar(30) not null
- );
- create table if not exists ceramica(
- cod_trans int,
- cod_marca int,
- medida varchar(9),
- descrip varchar(100),
- calidad varchar(10),
- metros decimal(6,2) ,
- precio decimal(5,2),
- stock int,
- activo boolean not null,
- cod_suc int,
- primary key(cod_marca,medida,descrip,calidad,cod_suc),
- index(cod_marca,medida,descrip,calidad,cod_suc),
- CONSTRAINT Ceramica_Transito_FK FOREIGN KEY(cod_trans)
- REFERENCES transito(cod),
- CONSTRAINT Ceramica_CodMarca_FK FOREIGN KEY(cod_marca)
- REFERENCES marca(cod),
- CONSTRAINT Ceramica_Medida_FK FOREIGN KEY(medida)
- REFERENCES medida(descrip),
- CONSTRAINT Ceramica_CodSuc_FK FOREIGN KEY(cod_suc)
- REFERENCES sucursal(cod),
- CONSTRAINT Ceramica_Calidad_FK FOREIGN KEY(calidad)
- REFERENCES calidad(descrip))ENGINE=InnoDB;
- create table if not exists vende(
- cod_vend int,
- cod_marca int not null,
- medida varchar(9) not null,
- descrip varchar(100)not null,
- calidad varchar(10)not null,
- cant int not null,
- precio decimal(6,2) not null,
- fecha datetime,
- factura int not null,
- cod_tipo int not null,
- primary key(cod_vend,fecha),
- index(cod_marca,medida,descrip,calidad),
- CONSTRAINT Vende_CodVend_FK FOREIGN KEY(cod_vend)
- REFERENCES vendedor(cod),
- CONSTRAINT Vende_CodTipo_FK FOREIGN KEY(cod_tipo)
- REFERENCES tipoventa(cod),
- FOREIGN KEY Vende_Ceramica_FK(cod_marca,medida,descrip,calidad)
- REFERENCES ceramica(cod_marca,medida,descrip,calidad))ENGINE=InnoDB;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement