[Php-avanzado] BD tesis Carrito de compras

Mauro Giuffo maurogiuffo en gmail.com
Sab Dic 13 12:17:28 ART 2008


Hola Leo :

te mando la estructura de la base de datos para la tesis Carrito de compras.
Todavia no me quedo claro como armar la tabla del detalle de los pedidos, ya
que los articulos pueden desaparecer segun la lista que llegue del sistema
externo que la genera.



----------------------------------------------------------------

/*
Created 13/12/2008
Modified 13/12/2008
Project
Model
Company
Author
Version
Database mySQL 5
*/


Create table tipos_usuario (
 id Int UNSIGNED NOT NULL AUTO_INCREMENT,
 nombre Varchar(20) NOT NULL,
 UNIQUE (nombre),
 Primary Key (id)) ENGINE = MyISAM;

Create table usuarios (
 id Int UNSIGNED NOT NULL AUTO_INCREMENT,
 id_tipo Int UNSIGNED NOT NULL,
 nombre Varchar(20) NOT NULL,
 password Varchar(20) NOT NULL,
 email Varchar(60) NOT NULL,
 UNIQUE (nombre),
 UNIQUE (email),
 Primary Key (id)) ENGINE = MyISAM;

Create table articulos (
 id Int UNSIGNED NOT NULL AUTO_INCREMENT,
 id_familia Char(20) UNSIGNED NOT NULL,
 id_marca Char(20) UNSIGNED NOT NULL,
 id_grupo Char(20) UNSIGNED NOT NULL,
 codigo Varchar(20) NOT NULL,
 descripcion Varchar(60) NOT NULL,
 precio Decimal(10,3) NOT NULL,
 UNIQUE (codigo),
 Primary Key (id)) ENGINE = MyISAM;

Create table familias (
 id Char(20) UNSIGNED NOT NULL AUTO_INCREMENT,
 descripcion Varchar(60) NOT NULL,
 Primary Key (id)) ENGINE = MyISAM;

Create table marcas (
 id Char(20) UNSIGNED NOT NULL AUTO_INCREMENT,
 descripcion Varchar(60) NOT NULL,
 Primary Key (id)) ENGINE = MyISAM;

Create table grupos (
 id Char(20) UNSIGNED NOT NULL AUTO_INCREMENT,
 descripcion Varchar(60) NOT NULL,
 Primary Key (id)) ENGINE = MyISAM;

Create table pedidos (
 id Int UNSIGNED NOT NULL AUTO_INCREMENT,
 id_estado Int UNSIGNED NOT NULL,
 id_usuario Int UNSIGNED NOT NULL,
 fecha Date NOT NULL,
 Primary Key (id)) ENGINE = MyISAM;

Create table estados (
 id Int UNSIGNED NOT NULL AUTO_INCREMENT,
 nombre Varchar(20) NOT NULL,
 UNIQUE (nombre),
 Primary Key (id)) ENGINE = MyISAM;

Create table pedidos_det (
 id_pedido Int UNSIGNED NOT NULL,
 id_articulo Int UNSIGNED NOT NULL,
 codigo Varchar(20) NOT NULL,
 descripcion Varchar(60) NOT NULL,
 precio Decimal(10,3) NOT NULL,
 cantidad Int NOT NULL,
 Primary Key (id_pedido,id_articulo)) ENGINE = MyISAM;


Alter table usuarios add Foreign Key (id_tipo) references tipos_usuario (id)
on delete restrict on update restrict;
Alter table pedidos add Foreign Key (id_usuario) references usuarios (id) on
delete restrict on update restrict;
Alter table pedidos_det add Foreign Key (id_articulo) references articulos
(id) on delete restrict on update restrict;
Alter table articulos add Foreign Key (id_familia) references familias (id)
on delete restrict on update restrict;
Alter table articulos add Foreign Key (id_marca) references marcas (id) on
delete restrict on update restrict;
Alter table articulos add Foreign Key (id_grupo) references grupos (id) on
delete restrict on update restrict;
Alter table pedidos_det add Foreign Key (id_pedido) references pedidos (id)
on delete restrict on update restrict;
Alter table pedidos add Foreign Key (id_estado) references estados (id) on
delete restrict on update restrict;

----------------------------------------------------------------

Saludos
Mauro Giuffo
------------ próxima parte ------------
Se ha borrado un adjunto en formato HTML...
URL: http://www3.fi.mdp.edu.ar/cgi-bin/mailman/private/php-avanzado/attachments/20081213/fcfdef28/attachment-0001.htm 
------------ próxima parte ------------
Se ha borrado un mensaje que no está en formato texto plano...
Nombre     : export.jpg
Tipo       : image/jpeg
Tamaño     : 43582 bytes
Descripción: no disponible
Url        : http://www3.fi.mdp.edu.ar/cgi-bin/mailman/private/php-avanzado/attachments/20081213/fcfdef28/attachment-0001.jpg 


Más información sobre la lista de distribución Php-avanzado