16/05/2011, 19:54
|
| | Fecha de Ingreso: septiembre-2010
Mensajes: 39
Antigüedad: 14 años, 2 meses Puntos: 0 | |
Respuesta: Base de datos comercio - ¿Esta bien? Cita:
Iniciado por Pablus00 las imagenes no se ven...
Código:
CREATE TABLE category (
category_id INT(3) UNSIGNED NOT NULL AUTO_INCREMENT,
category_desc VARCHAR(50) DEFAULT NULL,
PRIMARY KEY (category_id)
) ENGINE=InnoDB;
CREATE TABLE items (
item_id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
i_name VARCHAR(80) NOT NULL DEFAULT '',
i_price FLOAT(5,2) NOT NULL DEFAULT '0',
i_stock INT(11) NOT NULL DEFAULT '0',
i_img BLOB,
i_date DATETIME NOT NULL,
i_description TEXT,
i_category INT(3) NOT NULL,
PRIMARY KEY (item_id)
) ENGINE=InnoDB;
CREATE TABLE users (
user_id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
u_name VARCHAR(35) DEFAULT NULL,
u_sname VARCHAR(35) DEFAULT NULL,
u_address VARCHAR(50) DEFAULT NULL,
u_city VARCHAR(50) DEFAULT NULL,
u_state VARCHAR(50) DEFAULT NULL,
u_country VARCHAR(50) DEFAULT NULL,
u_cp INT(6) UNSIGNED DEFAULT '0',
u_phone INT(11) DEFAULT '0',
u_dni INT(11) UNSIGNED DEFAULT '0',
u_email VARCHAR(60) DEFAULT NULL,
u_username VARCHAR(32) DEFAULT NULL,
u_password VARCHAR(32) DEFAULT NULL,
u_img BLOB,
u_online ENUM('on', 'off') DEFAULT 'off',
u_date DATETIME,
u_range ENUM('client', 'seller', 'admin') DEFAULT 'client',
PRIMARY KEY (user_id)
) ENGINE=InnoDB;
CREATE TABLE orders (
order_id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
client_id INT(11) UNSIGNED NOT NULL,
seller_id INT(11) UNSIGNED NOT NULL,
item_id INT(11) UNSIGNED NOT NULL,
o_date DATETIME,
o_amount FLOAT(5,2) NOT NULL DEFAULT '0',
o_status ENUM('confirmed', 'unconfirmed') DEFAULT 'unconfirmed',
PRIMARY KEY (order_id),
KEY client_id(client_id),
KEY seller_id(seller_id),
FOREIGN KEY (client_id) REFERENCES users(user_id),
FOREIGN KEY (seller_id) REFERENCES users(user_id)
) ENGINE=InnoDB;
CREATE TABLE questions (
question_id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
q_question TEXT,
q_client INT(11) UNSIGNED NOT NULL,
q_seller INT(11) UNSIGNED NOT NULL,
q_date DATETIME,
PRIMARY KEY (question_id),
KEY q_client (q_client),
KEY q_seller (q_seller),
FOREIGN KEY (q_client) REFERENCES users(user_id),
FOREIGN KEY (q_seller) REFERENCES users(user_id)
) ENGINE=InnoDB;
Mil disculpas; ... ahi esta como las hice en código |