CREATE DATABASE IF NOT EXISTS paintingBusiness;
USE paintingBusiness;

CREATE TABLE IF NOT EXISTS customers(
	customer_id INT NOT NULL PRIMARY KEY,
    first_name VARCHAR(25) NOT NULL,
    last_name VARCHAR(30) NOT NULL,
    `address` VARCHAR(255) NOT NULL,
    phone VARCHAR(15) NOT NULL,
    email VARCHAR(30) NOT NULL
);

CREATE TABLE IF NOT EXISTS employees(
	employee_id INT NOT NULL PRIMARY KEY,
    first_name VARCHAR(25) NOT NULL,
    last_name VARCHAR(30) NOT NULL,
    `address` VARCHAR(255) NOT NULL,
    hire_date DATETIME NOT NULL,
    salary INT NOT NULL
);

CREATE TABLE IF NOT EXISTS inventory(
	paint_id INT NOT NULL PRIMARY KEY,
    paint_name VARCHAR(30) NOT NULL,
    cost_per_can DECIMAL(5,2) NOT NULL,
    quantity INT NOT NULL
);

CREATE TABLE IF NOT EXISTS contracts(
	contract_id INT NOT NULL PRIMARY KEY,
    customer_id INT NOT NULL,
    employee_id INT NOT NULL,
    `address` VARCHAR(255) NOT NULL,
    scheduled_for DATETIME NOT NULL,
    FOREIGN KEY (customer_id) REFERENCES customers(customer_id),
    FOREIGN KEY (employee_id) REFERENCES employees(employee_id)
);

CREATE TABLE IF NOT EXISTS rooms(
	room_id INT NOT NULL PRIMARY KEY,
    contract_id INT NOT NULL,
    paint_id INT NOT NULL,
    room_name VARCHAR(30) NOT NULL,
    FOREIGN KEY (contract_id) REFERENCES contracts(contract_id),
    FOREIGN KEY (paint_id) REFERENCES inventory(paint_id)
);