67 lines
4.2 KiB
SQL
67 lines
4.2 KiB
SQL
-- Car Sales in Afghanistan - Database Schema
|
|
-- Prepared for University Final-Year Project (2026 Edition)
|
|
|
|
DROP TABLE IF EXISTS contact_messages;
|
|
DROP TABLE IF EXISTS cars;
|
|
DROP TABLE IF EXISTS users;
|
|
|
|
CREATE TABLE IF NOT EXISTS users (
|
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
name VARCHAR(100) NOT NULL,
|
|
email VARCHAR(100) NOT NULL UNIQUE,
|
|
password VARCHAR(255) NOT NULL,
|
|
role ENUM('admin', 'user') DEFAULT 'user',
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS cars (
|
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
user_id INT,
|
|
brand VARCHAR(50) NOT NULL,
|
|
model VARCHAR(50) NOT NULL,
|
|
year INT NOT NULL,
|
|
price DECIMAL(10, 2) NOT NULL,
|
|
city ENUM('Kabul', 'Herat', 'Mazar-i-Sharif', 'Kandahar', 'Jalalabad') NOT NULL,
|
|
description TEXT,
|
|
main_image VARCHAR(255),
|
|
status ENUM('available', 'sold') DEFAULT 'available',
|
|
is_hot_deal BOOLEAN DEFAULT FALSE,
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS contact_messages (
|
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
name VARCHAR(100) NOT NULL,
|
|
email VARCHAR(100) NOT NULL,
|
|
subject VARCHAR(200),
|
|
message TEXT NOT NULL,
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
|
|
-- Default Admin Account (Password: 12345678)
|
|
INSERT IGNORE INTO users (id, name, email, password, role) VALUES
|
|
(1, 'Mohammad Sadiq', 'admin@gmail.com', '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', 'admin');
|
|
|
|
-- 20 Cars in Afghanistan Details
|
|
TRUNCATE TABLE cars;
|
|
INSERT INTO cars (brand, model, year, price, city, main_image, is_hot_deal, description) VALUES
|
|
('Toyota', 'Corolla', 2015, 12500, 'Kabul', 'assets/images/cars/corolla.jpg', TRUE, 'Clean Toyota Corolla, very fuel efficient and popular in Kabul.'),
|
|
('Toyota', 'Hilux', 2022, 45000, 'Kabul', 'assets/images/cars/hilux.jpg', TRUE, 'Powerful Hilux for off-road and city use.'),
|
|
('Lexus', 'LX570', 2021, 95000, 'Kandahar', 'assets/images/cars/lx570.jpg', TRUE, 'Luxury and power combined. Top condition.'),
|
|
('Toyota', 'Camry', 2020, 22000, 'Mazar-i-Sharif', 'assets/images/cars/camry.jpg', FALSE, 'Reliable family sedan.'),
|
|
('Hyundai', 'Tucson', 2021, 24500, 'Jalalabad', 'assets/images/cars/tucson.jpg', FALSE, 'Modern SUV with great features.'),
|
|
|
|
('Kia', 'Sportage', 2022, 27000, 'Kabul', 'https://images.pexels.com/photos/170811/pexels-photo-170811.jpeg', TRUE, 'Stylish and comfortable compact SUV.'),
|
|
('Suzuki', 'Swift', 2018, 9500, 'Herat', 'https://images.pexels.com/photos/112460/pexels-photo-112460.jpeg', FALSE, 'Small but fast, perfect for city traffic.'),
|
|
('Toyota', 'Prado', 2019, 55000, 'Kandahar', 'https://images.pexels.com/photos/1035108/pexels-photo-1035108.jpeg', FALSE, 'Robust SUV for all terrains.'),
|
|
('Mercedes-Benz', 'S-Class', 2022, 120000, 'Kabul', 'https://images.pexels.com/photos/112460/pexels-photo-112460.jpeg', FALSE, 'Ultimate luxury for high-profile individuals.'),
|
|
('Toyota', 'Surf', 2005, 13500, 'Mazar-i-Sharif', 'https://images.pexels.com/photos/1035108/pexels-photo-1035108.jpeg', FALSE, 'Classic off-roader, very durable.'),
|
|
('Honda', 'Civic', 2017, 16000, 'Kabul', 'https://images.pexels.com/photos/3311574/pexels-photo-3311574.jpeg', FALSE, 'Sharp design and great performance.'),
|
|
('Range Rover', 'Vogue', 2023, 180000, 'Kabul', 'https://images.pexels.com/photos/112460/pexels-photo-112460.jpeg', TRUE, 'The pinnacle of luxury SUVs.'),
|
|
('Toyota', 'Hiace', 2016, 18000, 'Jalalabad', 'https://images.pexels.com/photos/170811/pexels-photo-170811.jpeg', FALSE, 'Best van for passenger transport.'),
|
|
('Chevrolet', 'Camaro', 2019, 35000, 'Kabul', 'https://images.pexels.com/photos/3311574/pexels-photo-3311574.jpeg', FALSE, 'Muscle car for speed enthusiasts.'),
|
|
('Ford', 'Mustang', 2020, 38000, 'Herat', 'https://images.pexels.com/photos/112460/pexels-photo-112460.jpeg', FALSE, 'Iconic American muscle.'),
|
|
('Toyota', 'Vitz', 2015, 7500, 'Kabul', 'https://images.pexels.com/photos/3311574/pexels-photo-3311574.jpeg', FALSE, 'Compact and very fuel efficient.'),
|
|
('Lexus', 'RX350', 2018, 42000, 'Mazar-i-Sharif', 'https://images.pexels.com/photos/170811/pexels-photo-170811.jpeg', FALSE, 'Premium crossover with smooth ride.');
|