You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CREATE DATABASE IF NOT EXISTS rentalsystem
DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
2. 해당 DataBase 이동
USE rentalsystem;
3. user Table 생성
CREATE TABLE IF NOT EXISTS user (
id INT AUTO_INCREMENT PRIMARY KEY,
userId VARCHAR(100) NOT NULL UNIQUE,
pw VARCHAR(255) NOT NULL,
name VARCHAR(100) NOT NULL,
phoneNumber VARCHAR(50) UNIQUE,
cardNumber VARCHAR(50),
membership VARCHAR(50)
);
4. car Table 생성
CREATE TABLE IF NOT EXISTS car (
id INT AUTO_INCREMENT PRIMARY KEY,
type ENUM('SEDAN', 'SUV', 'BIKE') NOT NULL,
name VARCHAR(100) NOT NULL,
status VARCHAR(50) NOT NULL,
dailyRentalFee DECIMAL(10, 2)
);
5. rental Table 생성
CREATE TABLE IF NOT EXISTS rental (
id INT AUTO_INCREMENT PRIMARY KEY,
userId INT NOT NULL,
carId INT NOT NULL,
startTime DATETIME NOT NULL,
endTime DATETIME NOT NULL,
status VARCHAR(50) NOT NULL,
FOREIGN KEY (userId) REFERENCES user(id) ON DELETE CASCADE,
FOREIGN KEY (carId) REFERENCES car(id)
);