USE shopping;
CREATE TABLE products ( id INT AUTO_INCREMENT PRIMARY KEY, description VARCHAR(255) NOT NULL, image VARCHAR(255), pricing DECIMAL(10, 2) NOT NULL, shipping_cost DECIMAL(10, 2) NOT NULL );
CREATE TABLE users ( id INT AUTO_INCREMENT PRIMARY KEY, email VARCHAR(255) NOT NULL, password VARCHAR(255) NOT NULL, username VARCHAR(100) NOT NULL, purchase_history TEXT, shipping_address TEXT );
CREATE TABLE comments ( id INT AUTO_INCREMENT PRIMARY KEY, product_id INT NOT NULL, user_id INT NOT NULL, rating INT NOT NULL, image VARCHAR(255), comment_text TEXT, FOREIGN KEY (product_id) REFERENCES products(id), FOREIGN KEY (user_id) REFERENCES users(id) );
CREATE TABLE cart ( id INT AUTO_INCREMENT PRIMARY KEY, user_id INT NOT NULL, product_id INT NOT NULL, quantity INT NOT NULL, FOREIGN KEY (user_id) REFERENCES users(id), FOREIGN KEY (product_id) REFERENCES products(id) );
CREATE TABLE orders ( id INT AUTO_INCREMENT PRIMARY KEY, user_id INT NOT NULL, product_id INT NOT NULL, quantity INT NOT NULL, total_amount DECIMAL(10, 2) NOT NULL, order_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY (user_id) REFERENCES users(id), FOREIGN KEY (product_id) REFERENCES products(id) );