{"Addresses": {"columns": [[0, "address_id", "INTEGER", 0, null, 1], [1, "line_1_number_building", "VARCHAR(80)", 0, null, 0], [2, "town_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": []}, "Services": {"columns": [[0, "service_id", "INTEGER", 0, null, 1], [1, "service_type_code", "VARCHAR(15)", 1, null, 0], [2, "service_name", "VARCHAR(80)", 0, null, 0], [3, "service_descriptio", "VARCHAR(255)", 0, null, 0]], "primary_keys": ["service_id"], "foreign_keys": [], "unique_constraints": [], "check_constraints": []}, "Forms": {"columns": [[0, "form_id", "INTEGER", 0, null, 1], [1, "form_type_code", "VARCHAR(15)", 1, null, 0], [2, "service_id", "INTEGER", 0, null, 0], [3, "form_number", "VARCHAR(50)", 0, null, 0], [4, "form_name", "VARCHAR(80)", 0, null, 0], [5, "form_description", "VARCHAR(255)", 0, null, 0]], "primary_keys": ["form_id"], "foreign_keys": [[0, 0, "Services", "service_id", "service_id", "NO ACTION", "NO ACTION", "NONE"]], "unique_constraints": [], "check_constraints": []}, "Individuals": {"columns": [[0, "individual_id", "INTEGER", 0, null, 1], [1, "individual_first_name", "VARCHAR(80)", 0, null, 0], [2, "individual_middle_name", "VARCHAR(80)", 0, null, 0], [3, "inidividual_phone", "VARCHAR(80)", 0, null, 0], [4, "individual_email", "VARCHAR(80)", 0, null, 0], [5, "individual_address", "VARCHAR(255)", 0, null, 0], [6, "individual_last_name", "VARCHAR(80)", 0, null, 0]], "primary_keys": ["individual_id"], "foreign_keys": [], "unique_constraints": [], "check_constraints": []}, "Organizations": {"columns": [[0, "organization_id", "INTEGER", 0, null, 1], [1, "date_formed", "DATETIME", 0, null, 0], [2, "organization_name", "VARCHAR(255)", 0, null, 0], [3, "uk_vat_number", "VARCHAR(20)", 0, null, 0]], "primary_keys": ["organization_id"], "foreign_keys": [], "unique_constraints": [], "check_constraints": []}, "Parties": {"columns": [[0, "party_id", "INTEGER", 0, null, 1], [1, "payment_method_code", "VARCHAR(15)", 1, null, 0], [2, "party_phone", "VARCHAR(80)", 0, null, 0], [3, "party_email", "VARCHAR(80)", 0, null, 0]], "primary_keys": ["party_id"], "foreign_keys": [], "unique_constraints": [], "check_constraints": []}, "Organization_Contact_Individuals": {"columns": [[0, "individual_id", "INTEGER", 1, null, 1], [1, "organization_id", "INTEGER", 1, null, 2], [2, "date_contact_from", "DATETIME", 1, null, 0], [3, "date_contact_to", "DATETIME", 0, null, 0]], "primary_keys": ["individual_id", "organization_id"], "foreign_keys": [[0, 0, "Individuals", "individual_id", "individual_id", "NO ACTION", "NO ACTION", "NONE"], [1, 0, "Organizations", "organization_id", "organization_id", "NO ACTION", "NO ACTION", "NONE"]], "unique_constraints": [[[0, 0, "individual_id"], [1, 1, "organization_id"]]], "check_constraints": []}, "Party_Addresses": {"columns": [[0, "party_id", "INTEGER", 1, null, 1], [1, "address_id", "INTEGER", 1, null, 2], [2, "date_address_from", "DATETIME", 1, null, 0], [3, "address_type_code", "VARCHAR(15)", 1, null, 0], [4, "date_address_to", "DATETIME", 0, null, 0]], "primary_keys": ["party_id", "address_id"], "foreign_keys": [[0, 0, "Parties", "party_id", "party_id", "NO ACTION", "NO ACTION", "NONE"], [1, 0, "Addresses", "address_id", "address_id", "NO ACTION", "NO ACTION", "NONE"]], "unique_constraints": [[[0, 0, "party_id"], [1, 1, "address_id"]]], "check_constraints": []}, "Party_Forms": {"columns": [[0, "party_id", "INTEGER", 1, null, 1], [1, "form_id", "INTEGER", 1, null, 2], [2, "date_completion_started", "DATETIME", 1, null, 0], [3, "form_status_code", "VARCHAR(15)", 1, null, 0], [4, "date_fully_completed", "DATETIME", 0, null, 0]], "primary_keys": ["party_id", "form_id"], "foreign_keys": [[0, 0, "Forms", "form_id", "form_id", "NO ACTION", "NO ACTION", "NONE"], [1, 0, "Parties", "party_id", "party_id", "NO ACTION", "NO ACTION", "NONE"]], "unique_constraints": [[[0, 0, "party_id"], [1, 1, "form_id"]]], "check_constraints": []}, "Party_Services": {"columns": [[0, "booking_id", "INTEGER", 1, null, 0], [1, "customer_id", "INTEGER", 1, null, 0], [2, "service_id", "INTEGER", 1, null, 0], [3, "service_datetime", "DATETIME", 1, null, 0], [4, "booking_made_date", "DATETIME", 0, null, 0]], "primary_keys": [], "foreign_keys": [[0, 0, "Parties", "customer_id", "party_id", "NO ACTION", "NO ACTION", "NONE"], [1, 0, "Services", "service_id", "service_id", "NO ACTION", "NO ACTION", "NONE"]], "unique_constraints": [], "check_constraints": []}}
CREATE TABLE Addresses (
    address_id INTEGER   PRIMARY KEY,
    line_1_number_building VARCHAR(80),
    town_city VARCHAR(50),
    zip_postcode VARCHAR(20),
    state_province_county VARCHAR(50),
    country VARCHAR(50)
);

CREATE TABLE Services (
    service_id INTEGER   PRIMARY KEY,
    service_type_code VARCHAR(15) NOT NULL,
    service_name VARCHAR(80),
    service_descriptio VARCHAR(255)
);

CREATE TABLE Forms (
    form_id INTEGER   PRIMARY KEY,
    form_type_code VARCHAR(15) NOT NULL,
    service_id INTEGER,
    form_number VARCHAR(50),
    form_name VARCHAR(80),
    form_description VARCHAR(255),
    FOREIGN KEY (service_id) REFERENCES Services(service_id)
);

CREATE TABLE Individuals (
    individual_id INTEGER   PRIMARY KEY,
    individual_first_name VARCHAR(80),
    individual_middle_name VARCHAR(80),
    inidividual_phone VARCHAR(80),
    individual_email VARCHAR(80),
    individual_address VARCHAR(255),
    individual_last_name VARCHAR(80)
);

CREATE TABLE Organizations (
    organization_id INTEGER   PRIMARY KEY,
    date_formed DATETIME,
    organization_name VARCHAR(255),
    uk_vat_number VARCHAR(20)
);

CREATE TABLE Parties (
    party_id INTEGER   PRIMARY KEY,
    payment_method_code VARCHAR(15) NOT NULL,
    party_phone VARCHAR(80),
    party_email VARCHAR(80)
);

CREATE TABLE Organization_Contact_Individuals (
    individual_id INTEGER NOT NULL  PRIMARY KEY,
    organization_id INTEGER NOT NULL  PRIMARY KEY,
    date_contact_from DATETIME NOT NULL,
    date_contact_to DATETIME,
    PRIMARY KEY (individual_id, organization_id),
    UNIQUE (individual_id, organization_id),
    FOREIGN KEY (individual_id) REFERENCES Individuals(individual_id),
    FOREIGN KEY (organization_id) REFERENCES Organizations(organization_id)
);

CREATE TABLE Party_Addresses (
    party_id INTEGER NOT NULL  PRIMARY KEY,
    address_id INTEGER NOT NULL  PRIMARY KEY,
    date_address_from DATETIME NOT NULL,
    address_type_code VARCHAR(15) NOT NULL,
    date_address_to DATETIME,
    PRIMARY KEY (party_id, address_id),
    UNIQUE (party_id, address_id),
    FOREIGN KEY (party_id) REFERENCES Parties(party_id),
    FOREIGN KEY (address_id) REFERENCES Addresses(address_id)
);

CREATE TABLE Party_Forms (
    party_id INTEGER NOT NULL  PRIMARY KEY,
    form_id INTEGER NOT NULL  PRIMARY KEY,
    date_completion_started DATETIME NOT NULL,
    form_status_code VARCHAR(15) NOT NULL,
    date_fully_completed DATETIME,
    PRIMARY KEY (party_id, form_id),
    UNIQUE (party_id, form_id),
    FOREIGN KEY (form_id) REFERENCES Forms(form_id),
    FOREIGN KEY (party_id) REFERENCES Parties(party_id)
);

CREATE TABLE Party_Services (
    booking_id INTEGER NOT NULL,
    customer_id INTEGER NOT NULL,
    service_id INTEGER NOT NULL,
    service_datetime DATETIME NOT NULL,
    booking_made_date DATETIME,
    FOREIGN KEY (customer_id) REFERENCES Parties(party_id),
    FOREIGN KEY (service_id) REFERENCES Services(service_id)
);