-- Create ERP database and user CREATE DATABASE IF NOT EXISTS erp_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; USE erp_db; -- Create tables for ERP system CREATE TABLE IF NOT EXISTS products ( id BIGINT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255) NOT NULL, description TEXT, price DECIMAL(10,2), stock_quantity INT DEFAULT 0, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ); CREATE TABLE IF NOT EXISTS categories ( id BIGINT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100) NOT NULL UNIQUE, description TEXT, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ); CREATE TABLE IF NOT EXISTS suppliers ( id BIGINT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255) NOT NULL, email VARCHAR(255), phone VARCHAR(50), address TEXT, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ); -- Insert sample data INSERT INTO categories (name, description) VALUES ('Electronics', 'Electronic devices and accessories'), ('Clothing', 'Apparel and fashion items'), ('Food', 'Food and beverages'), ('Books', 'Books and educational materials'); INSERT INTO products (name, description, price, stock_quantity) VALUES ('Laptop Pro', 'High-performance laptop for professionals', 1299.99, 50), ('Wireless Mouse', 'Ergonomic wireless mouse', 29.99, 200), ('Office Chair', 'Comfortable office chair with lumbar support', 199.99, 25); INSERT INTO suppliers (name, email, phone, address) VALUES ('Tech Supply Co', 'info@techsupply.com', '+1-555-0101', '123 Tech Street, Silicon Valley, CA 94025'), ('Office Essentials', 'sales@officeess.com', '+1-555-0102', '456 Business Ave, Commerce City, NY 10001'); -- Create indexes for better performance CREATE INDEX idx_products_name ON products(name); CREATE INDEX idx_products_category ON products(name); CREATE INDEX idx_suppliers_name ON suppliers(name);