{"Addresses": {"columns": [[0, "address_id", "INTEGER", 0, null, 1], [1, "line_1_number_building", "VARCHAR(80)", 0, null, 0], [2, "city", "VARCHAR(50)", 0, null, 0], [3, "zip_postcode", "VARCHAR(20)", 0, null, 0], [4, "state_province_county", "VARCHAR(50)", 0, null, 0], [5, "country", "VARCHAR(50)", 0, null, 0]], "primary_keys": ["address_id"], "foreign_keys": [], "unique_constraints": [], "check_constraints": []}, "Staff": {"columns": [[0, "staff_id", "INTEGER", 0, null, 1], [1, "staff_address_id", "INTEGER", 1, null, 0], [2, "nickname", "VARCHAR(80)", 0, null, 0], [3, "first_name", "VARCHAR(80)", 0, null, 0], [4, "middle_name", "VARCHAR(80)", 0, null, 0], [5, "last_name", "VARCHAR(80)", 0, null, 0], [6, "date_of_birth", "DATETIME", 0, null, 0], [7, "date_joined_staff", "DATETIME", 0, null, 0], [8, "date_left_staff", "DATETIME", 0, null, 0]], "primary_keys": ["staff_id"], "foreign_keys": [[0, 0, "Addresses", "staff_address_id", "address_id", "NO ACTION", "NO ACTION", "NONE"]], "unique_constraints": [], "check_constraints": []}, "Vehicles": {"columns": [[0, "vehicle_id", "INTEGER", 0, null, 1], [1, "vehicle_details", "VARCHAR(255)", 0, null, 0]], "primary_keys": ["vehicle_id"], "foreign_keys": [], "unique_constraints": [], "check_constraints": []}, "Customers": {"columns": [[0, "customer_id", "INTEGER", 0, null, 1], [1, "customer_address_id", "INTEGER", 1, null, 0], [2, "customer_status_code", "VARCHAR(15)", 1, null, 0], [3, "date_became_customer", "DATETIME", 0, null, 0], [4, "date_of_birth", "DATETIME", 0, null, 0], [5, "first_name", "VARCHAR(80)", 0, null, 0], [6, "last_name", "VARCHAR(80)", 0, null, 0], [7, "amount_outstanding", "DOUBLE", 0, null, 0], [8, "email_address", "VARCHAR(250)", 0, null, 0], [9, "phone_number", "VARCHAR(255)", 0, null, 0], [10, "cell_mobile_phone_number", "VARCHAR(255)", 0, null, 0]], "primary_keys": ["customer_id"], "foreign_keys": [[0, 0, "Addresses", "customer_address_id", "address_id", "NO ACTION", "NO ACTION", "NONE"]], "unique_constraints": [], "check_constraints": []}, "Customer_Payments": {"columns": [[0, "customer_id", "INTEGER", 1, null, 1], [1, "datetime_payment", "DATETIME", 1, null, 2], [2, "payment_method_code", "VARCHAR(10)", 1, null, 0], [3, "amount_payment", "DOUBLE", 0, null, 0]], "primary_keys": ["customer_id", "datetime_payment"], "foreign_keys": [[0, 0, "Customers", "customer_id", "customer_id", "NO ACTION", "NO ACTION", "NONE"]], "unique_constraints": [[[0, 0, "customer_id"], [1, 1, "datetime_payment"]]], "check_constraints": []}, "Lessons": {"columns": [[0, "lesson_id", "INTEGER", 0, null, 1], [1, "customer_id", "INTEGER", 1, null, 0], [2, "lesson_status_code", "VARCHAR(15)", 1, null, 0], [3, "staff_id", "INTEGER", 0, null, 0], [4, "vehicle_id", "INTEGER", 1, null, 0], [5, "lesson_date", "DATETIME", 0, null, 0], [6, "lesson_time", "VARCHAR(10)", 0, null, 0], [7, "price", "DOUBLE", 0, null, 0]], "primary_keys": ["lesson_id"], "foreign_keys": [[0, 0, "Customers", "customer_id", "customer_id", "NO ACTION", "NO ACTION", "NONE"], [1, 0, "Staff", "staff_id", "staff_id", "NO ACTION", "NO ACTION", "NONE"], [2, 0, "Vehicles", "vehicle_id", "vehicle_id", "NO ACTION", "NO ACTION", "NONE"]], "unique_constraints": [], "check_constraints": []}}
CREATE TABLE Addresses (
    address_id INTEGER   PRIMARY KEY,
    line_1_number_building VARCHAR(80),
    city VARCHAR(50),
    zip_postcode VARCHAR(20),
    state_province_county VARCHAR(50),
    country VARCHAR(50)
);

CREATE TABLE Staff (
    staff_id INTEGER   PRIMARY KEY,
    staff_address_id INTEGER NOT NULL,
    nickname VARCHAR(80),
    first_name VARCHAR(80),
    middle_name VARCHAR(80),
    last_name VARCHAR(80),
    date_of_birth DATETIME,
    date_joined_staff DATETIME,
    date_left_staff DATETIME,
    FOREIGN KEY (staff_address_id) REFERENCES Addresses(address_id)
);

CREATE TABLE Vehicles (
    vehicle_id INTEGER   PRIMARY KEY,
    vehicle_details VARCHAR(255)
);

CREATE TABLE Customers (
    customer_id INTEGER   PRIMARY KEY,
    customer_address_id INTEGER NOT NULL,
    customer_status_code VARCHAR(15) NOT NULL,
    date_became_customer DATETIME,
    date_of_birth DATETIME,
    first_name VARCHAR(80),
    last_name VARCHAR(80),
    amount_outstanding DOUBLE,
    email_address VARCHAR(250),
    phone_number VARCHAR(255),
    cell_mobile_phone_number VARCHAR(255),
    FOREIGN KEY (customer_address_id) REFERENCES Addresses(address_id)
);

CREATE TABLE Customer_Payments (
    customer_id INTEGER NOT NULL  PRIMARY KEY,
    datetime_payment DATETIME NOT NULL  PRIMARY KEY,
    payment_method_code VARCHAR(10) NOT NULL,
    amount_payment DOUBLE,
    PRIMARY KEY (customer_id, datetime_payment),
    UNIQUE (customer_id, datetime_payment),
    FOREIGN KEY (customer_id) REFERENCES Customers(customer_id)
);

CREATE TABLE Lessons (
    lesson_id INTEGER   PRIMARY KEY,
    customer_id INTEGER NOT NULL,
    lesson_status_code VARCHAR(15) NOT NULL,
    staff_id INTEGER,
    vehicle_id INTEGER NOT NULL,
    lesson_date DATETIME,
    lesson_time VARCHAR(10),
    price DOUBLE,
    FOREIGN KEY (customer_id) REFERENCES Customers(customer_id),
    FOREIGN KEY (staff_id) REFERENCES Staff(staff_id),
    FOREIGN KEY (vehicle_id) REFERENCES Vehicles(vehicle_id)
);