|
| 1 | +create table categories( |
| 2 | +category_id serial primary key, |
| 3 | +name varchar(100) |
| 4 | + ) |
| 5 | + |
| 6 | +CREATE TABLE Products ( |
| 7 | + product_id SERIAL PRIMARY KEY, |
| 8 | + name VARCHAR(100), |
| 9 | + price DECIMAL(10, 2), |
| 10 | + description VARCHAR(255), |
| 11 | + tags VARCHAR(255), |
| 12 | + category_id INT, |
| 13 | + FOREIGN KEY (category_id) REFERENCES categories(category_id), |
| 14 | + Supplier VARCHAR(100) |
| 15 | +); |
| 16 | + |
| 17 | + |
| 18 | +CREATE TABLE Customer ( |
| 19 | + customer_id SERIAL PRIMARY KEY, |
| 20 | + customer_name VARCHAR(100) NOT NULL, |
| 21 | + email VARCHAR(100) NOT NULL, |
| 22 | + phone_number VARCHAR(20), |
| 23 | + address VARCHAR(255), |
| 24 | + City VARCHAR(255) |
| 25 | +); |
| 26 | + |
| 27 | + |
| 28 | + CREATE TABLE Orders ( |
| 29 | + order_id SERIAL PRIMARY KEY, |
| 30 | + customer_id INT, |
| 31 | + product_id INT, |
| 32 | + total_quantity INT, |
| 33 | + total_amount DECIMAL(10, 2), |
| 34 | + order_rating DECIMAL(3, 1), |
| 35 | + length DECIMAL(5, 2), |
| 36 | + width DECIMAL(5, 2), |
| 37 | + order_timestamp TIMESTAMP, |
| 38 | + delivery_timestamp TIMESTAMP, |
| 39 | + FOREIGN KEY (customer_id) REFERENCES Customer(customer_id), |
| 40 | + FOREIGN KEY (product_id) REFERENCES Products(product_id) |
| 41 | +); |
| 42 | + |
| 43 | + |
| 44 | +INSERT INTO Categories (name) VALUES ('Electronics'), ('Clothing'), ('Home and Kitchen') |
| 45 | + |
| 46 | + |
| 47 | +INSERT INTO Products (name, price, description, tags, category_id,Supplier) |
| 48 | +VALUES |
| 49 | + ('Laptop', NULL, 'High-performance laptop for professionals', 'electronics, portable, tech', 1, 'SupplierA'), |
| 50 | + |
| 51 | + ('Headphones', 129.99, 'Over-ear wireless headphones', 'electronics, audio, accessories', 1, 'SupplierB'), |
| 52 | + |
| 53 | + ('Backpack', 49.99, 'Stylish and durable backpack for everyday use', 'fashion, accessories, travel', 2, 'NULL'), |
| 54 | + |
| 55 | + ('Coffee Maker', NULL, 'Automatic drip coffee maker with programmable timer', 'home, kitchen, appliances', 3, 'NULL'), |
| 56 | + |
| 57 | + ('Fitness Tracker', 79.99, 'Water-resistant fitness tracker with heart rate monitor', 'electronics, fitness, wearables', 1, 'NULL'); |
| 58 | + |
| 59 | + |
| 60 | + |
| 61 | + |
| 62 | +INSERT INTO Customer (customer_name, email, phone_number, address, city) VALUES |
| 63 | + ( 'Alice Johnson', '[email protected]', '123-456-7890', '123 Main St', 'Cityville'), |
| 64 | + ( 'Bob Smith', '[email protected]', '987-654-3210', '456 Oak Ave', 'Townsville'), |
| 65 | + ( 'Charlie Brown', '[email protected]', '555-123-4567', '789 Pine Ln', 'New York'), |
| 66 | + ( 'David White', '[email protected]', '222-333-4444', '567 Maple Dr', 'NYC'), |
| 67 | + ( 'Eva Black', '[email protected]', '999-888-7777', '890 Cedar Rd', 'Big Apple'), |
| 68 | + ( 'Frank Green', '[email protected]', '111-222-3333', '123 Elm St', 'Gotham City'); |
| 69 | + |
| 70 | + |
| 71 | + |
| 72 | +INSERT INTO Orders (customer_id, product_id, total_quantity, total_amount, order_rating, length, width, order_timestamp, delivery_timestamp) |
| 73 | +VALUES |
| 74 | + (1, 1, 5, 120.50, 4.5, 2.3, 1.8, '2023-01-15 10:30:00', '2023-01-16 15:45:00'), |
| 75 | + (2, 2, 3, 75.25, 3.8, 1.5, 1.2, '2023-02-03 14:20:00', '2023-02-05 11:10:00'), |
| 76 | + (3, 3, 7, 210.75, 4.2, 2.8, 2.0, '2023-03-12 08:45:00', '2023-03-14 09:30:00'), |
| 77 | + (1, 4, 2, 50.00, 4.0, 1.8, 1.5, '2023-04-05 12:15:00', '2023-04-07 18:20:00'); |
| 78 | + |
| 79 | + |
| 80 | +select * from categories |
| 81 | +select * from Orders |
| 82 | +select * from Customer |
| 83 | +select * from Products |
0 commit comments