SET AUTOCOMMIT=1;

CREATE DATABASE IF NOT EXISTS botiga_php_db charset utf8;

USE botiga_php_db; 

DROP TABLE IF EXISTS bp_products;
DROP TABLE IF EXISTS bp_categories;
DROP TABLE IF EXISTS bp_users;

CREATE TABLE IF NOT EXISTS botiga_php_db.bp_users (
 bp_user_id             INT AUTO_INCREMENT,
 bp_user_name           VARCHAR(14) NOT NULL UNIQUE,
 bp_user_pass           VARCHAR(64) NOT NULL UNIQUE,
 bp_user_addDate        DATE NOT NULL,
 PRIMARY KEY (bp_user_id) ) ;

 CREATE TABLE IF NOT EXISTS botiga_php_db.bp_categories (
 bp_category_id         INT AUTO_INCREMENT,
 bp_category_name       VARCHAR(14) NOT NULL UNIQUE,
 PRIMARY KEY (bp_category_id) ) ;

 CREATE TABLE IF NOT EXISTS botiga_php_db.bp_products (
 bp_product_id     INT AUTO_INCREMENT,
 bp_product_name   VARCHAR(14) NOT NULL UNIQUE,
 bp_product_addDate   VARCHAR(64) NOT NULL,
 bp_product_category INT,
 PRIMARY KEY (bp_product_id),
 FOREIGN KEY (bp_product_category) REFERENCES bp_categories(bp_category_id) ) ;