-- Schema: finance_kaggle
CREATE SCHEMA IF NOT EXISTS "finance_kaggle";

-- Table: Loan_Default
CREATE TABLE "finance_kaggle"."Loan_Default" (
    "id" INTEGER,
    "year" INTEGER,
    "loan_limit" TEXT,
    "gender" TEXT,
    "approv_in_adv" TEXT,
    "loan_type" TEXT,
    "loan_purpose" TEXT,
    "credit_worthiness" TEXT,
    "open_credit" TEXT,
    "business_or_commercial" TEXT,
    "loan_amount" INTEGER,
    "rate_of_interest" DOUBLE PRECISION,
    "interest_rate_spread" DOUBLE PRECISION,
    "upfront_charges" DOUBLE PRECISION,
    "term" DOUBLE PRECISION,
    "neg_ammortization" TEXT,
    "interest_only" TEXT,
    "lump_sum_payment" TEXT,
    "property_value" DOUBLE PRECISION,
    "construction_type" TEXT,
    "occupancy_type" TEXT,
    "secured_by" TEXT,
    "total_units" TEXT,
    "income" DOUBLE PRECISION,
    "credit_type" TEXT,
    "credit_score" INTEGER,
    "co_applicant_credit_type" TEXT,
    "age" TEXT,
    "submission_of_application" TEXT,
    "ltv" DOUBLE PRECISION,
    "region" TEXT,
    "security_type" TEXT,
    "status" INTEGER,
    "dtir1" DOUBLE PRECISION
);

-- Table: account_statuses
CREATE TABLE "finance_kaggle"."account_statuses" (
    "accountstatusid" INTEGER,
    "statusname" TEXT
);

-- Table: account_types
CREATE TABLE "finance_kaggle"."account_types" (
    "accounttypeid" INTEGER,
    "typename" TEXT
);

-- Table: accounts
CREATE TABLE "finance_kaggle"."accounts" (
    "accountid" INTEGER,
    "customerid" INTEGER,
    "accounttypeid" INTEGER,
    "accountstatusid" INTEGER,
    "balance" DOUBLE PRECISION,
    "openingdate" TEXT
);

-- Table: addresses
CREATE TABLE "finance_kaggle"."addresses" (
    "addressid" INTEGER,
    "street" TEXT,
    "city" TEXT,
    "country" TEXT
);

-- Table: application_data
CREATE TABLE "finance_kaggle"."application_data" (
    "sk_id_curr" INTEGER,
    "target" INTEGER,
    "name_contract_type" TEXT,
    "code_gender" TEXT,
    "flag_own_car" TEXT,
    "flag_own_realty" TEXT,
    "cnt_children" INTEGER,
    "amt_income_total" DOUBLE PRECISION,
    "amt_credit" DOUBLE PRECISION,
    "amt_annuity" DOUBLE PRECISION,
    "amt_goods_price" DOUBLE PRECISION,
    "name_type_suite" TEXT,
    "name_income_type" TEXT,
    "name_education_type" TEXT,
    "name_family_status" TEXT,
    "name_housing_type" TEXT,
    "region_population_relative" DOUBLE PRECISION,
    "days_birth" INTEGER,
    "days_employed" INTEGER,
    "days_registration" DOUBLE PRECISION,
    "days_id_publish" INTEGER,
    "own_car_age" DOUBLE PRECISION,
    "flag_mobil" INTEGER,
    "flag_emp_phone" INTEGER,
    "flag_work_phone" INTEGER,
    "flag_cont_mobile" INTEGER,
    "flag_phone" INTEGER,
    "flag_email" INTEGER,
    "occupation_type" TEXT,
    "cnt_fam_members" DOUBLE PRECISION,
    "region_rating_client" INTEGER,
    "region_rating_client_w_city" INTEGER,
    "weekday_appr_process_start" TEXT,
    "hour_appr_process_start" INTEGER,
    "reg_region_not_live_region" INTEGER,
    "reg_region_not_work_region" INTEGER,
    "live_region_not_work_region" INTEGER,
    "reg_city_not_live_city" INTEGER,
    "reg_city_not_work_city" INTEGER,
    "live_city_not_work_city" INTEGER,
    "organization_type" TEXT,
    "ext_source_1" DOUBLE PRECISION,
    "ext_source_2" DOUBLE PRECISION,
    "ext_source_3" DOUBLE PRECISION,
    "apartments_avg" DOUBLE PRECISION,
    "basementarea_avg" DOUBLE PRECISION,
    "years_beginexpluatation_avg" DOUBLE PRECISION,
    "years_build_avg" DOUBLE PRECISION,
    "commonarea_avg" DOUBLE PRECISION,
    "elevators_avg" DOUBLE PRECISION,
    "entrances_avg" DOUBLE PRECISION,
    "floorsmax_avg" DOUBLE PRECISION,
    "floorsmin_avg" DOUBLE PRECISION,
    "landarea_avg" DOUBLE PRECISION,
    "livingapartments_avg" DOUBLE PRECISION,
    "livingarea_avg" DOUBLE PRECISION,
    "nonlivingapartments_avg" DOUBLE PRECISION,
    "nonlivingarea_avg" DOUBLE PRECISION,
    "apartments_mode" DOUBLE PRECISION,
    "basementarea_mode" DOUBLE PRECISION,
    "years_beginexpluatation_mode" DOUBLE PRECISION,
    "years_build_mode" DOUBLE PRECISION,
    "commonarea_mode" DOUBLE PRECISION,
    "elevators_mode" DOUBLE PRECISION,
    "entrances_mode" DOUBLE PRECISION,
    "floorsmax_mode" DOUBLE PRECISION,
    "floorsmin_mode" DOUBLE PRECISION,
    "landarea_mode" DOUBLE PRECISION,
    "livingapartments_mode" DOUBLE PRECISION,
    "livingarea_mode" DOUBLE PRECISION,
    "nonlivingapartments_mode" DOUBLE PRECISION,
    "nonlivingarea_mode" DOUBLE PRECISION,
    "apartments_medi" DOUBLE PRECISION,
    "basementarea_medi" DOUBLE PRECISION,
    "years_beginexpluatation_medi" DOUBLE PRECISION,
    "years_build_medi" DOUBLE PRECISION,
    "commonarea_medi" DOUBLE PRECISION,
    "elevators_medi" DOUBLE PRECISION,
    "entrances_medi" DOUBLE PRECISION,
    "floorsmax_medi" DOUBLE PRECISION,
    "floorsmin_medi" DOUBLE PRECISION,
    "landarea_medi" DOUBLE PRECISION,
    "livingapartments_medi" DOUBLE PRECISION,
    "livingarea_medi" DOUBLE PRECISION,
    "nonlivingapartments_medi" DOUBLE PRECISION,
    "nonlivingarea_medi" DOUBLE PRECISION,
    "fondkapremont_mode" TEXT,
    "housetype_mode" TEXT,
    "totalarea_mode" DOUBLE PRECISION,
    "wallsmaterial_mode" TEXT,
    "emergencystate_mode" BOOLEAN,
    "obs_30_cnt_social_circle" DOUBLE PRECISION,
    "def_30_cnt_social_circle" DOUBLE PRECISION,
    "obs_60_cnt_social_circle" DOUBLE PRECISION,
    "def_60_cnt_social_circle" DOUBLE PRECISION,
    "days_last_phone_change" DOUBLE PRECISION,
    "flag_document_2" INTEGER,
    "flag_document_3" INTEGER,
    "flag_document_4" INTEGER,
    "flag_document_5" INTEGER,
    "flag_document_6" INTEGER,
    "flag_document_7" INTEGER,
    "flag_document_8" INTEGER,
    "flag_document_9" INTEGER,
    "flag_document_10" INTEGER,
    "flag_document_11" INTEGER,
    "flag_document_12" INTEGER,
    "flag_document_13" INTEGER,
    "flag_document_14" INTEGER,
    "flag_document_15" INTEGER,
    "flag_document_16" INTEGER,
    "flag_document_17" INTEGER,
    "flag_document_18" INTEGER,
    "flag_document_19" INTEGER,
    "flag_document_20" INTEGER,
    "flag_document_21" INTEGER,
    "amt_req_credit_bureau_hour" DOUBLE PRECISION,
    "amt_req_credit_bureau_day" DOUBLE PRECISION,
    "amt_req_credit_bureau_week" DOUBLE PRECISION,
    "amt_req_credit_bureau_mon" DOUBLE PRECISION,
    "amt_req_credit_bureau_qrt" DOUBLE PRECISION,
    "amt_req_credit_bureau_year" DOUBLE PRECISION
);

-- Table: branches
CREATE TABLE "finance_kaggle"."branches" (
    "branchid" INTEGER,
    "branchname" TEXT,
    "addressid" INTEGER
);

-- Table: columns_description
CREATE TABLE "finance_kaggle"."columns_description" (
    "_" INTEGER,
    "table" TEXT,
    "row" TEXT,
    "description" TEXT,
    "special" TEXT
);

-- Table: creditcard
CREATE TABLE "finance_kaggle"."creditcard" (
    "time" INTEGER,
    "v1" DOUBLE PRECISION,
    "v2" DOUBLE PRECISION,
    "v3" DOUBLE PRECISION,
    "v4" DOUBLE PRECISION,
    "v5" DOUBLE PRECISION,
    "v6" DOUBLE PRECISION,
    "v7" DOUBLE PRECISION,
    "v8" DOUBLE PRECISION,
    "v9" DOUBLE PRECISION,
    "v10" DOUBLE PRECISION,
    "v11" DOUBLE PRECISION,
    "v12" DOUBLE PRECISION,
    "v13" DOUBLE PRECISION,
    "v14" DOUBLE PRECISION,
    "v15" DOUBLE PRECISION,
    "v16" DOUBLE PRECISION,
    "v17" DOUBLE PRECISION,
    "v18" DOUBLE PRECISION,
    "v19" DOUBLE PRECISION,
    "v20" DOUBLE PRECISION,
    "v21" DOUBLE PRECISION,
    "v22" DOUBLE PRECISION,
    "v23" DOUBLE PRECISION,
    "v24" DOUBLE PRECISION,
    "v25" DOUBLE PRECISION,
    "v26" DOUBLE PRECISION,
    "v27" DOUBLE PRECISION,
    "v28" DOUBLE PRECISION,
    "amount" DOUBLE PRECISION,
    "class" INTEGER
);

-- Table: customer_types
CREATE TABLE "finance_kaggle"."customer_types" (
    "customertypeid" INTEGER,
    "typename" TEXT
);

-- Table: customers
CREATE TABLE "finance_kaggle"."customers" (
    "customerid" INTEGER,
    "firstname" TEXT,
    "lastname" TEXT,
    "dateofbirth" TEXT,
    "addressid" INTEGER,
    "customertypeid" INTEGER
);

-- Table: loan_statuses
CREATE TABLE "finance_kaggle"."loan_statuses" (
    "loanstatusid" INTEGER,
    "statusname" TEXT
);

-- Table: loans
CREATE TABLE "finance_kaggle"."loans" (
    "loanid" INTEGER,
    "accountid" INTEGER,
    "loanstatusid" INTEGER,
    "principalamount" DOUBLE PRECISION,
    "interestrate" DOUBLE PRECISION,
    "startdate" TEXT,
    "estimatedenddate" TEXT
);

-- Table: previous_application
CREATE TABLE "finance_kaggle"."previous_application" (
    "sk_id_prev" INTEGER,
    "sk_id_curr" INTEGER,
    "name_contract_type" TEXT,
    "amt_annuity" DOUBLE PRECISION,
    "amt_application" DOUBLE PRECISION,
    "amt_credit" DOUBLE PRECISION,
    "amt_down_payment" DOUBLE PRECISION,
    "amt_goods_price" DOUBLE PRECISION,
    "weekday_appr_process_start" TEXT,
    "hour_appr_process_start" INTEGER,
    "flag_last_appl_per_contract" TEXT,
    "nflag_last_appl_in_day" INTEGER,
    "rate_down_payment" DOUBLE PRECISION,
    "rate_interest_primary" DOUBLE PRECISION,
    "rate_interest_privileged" DOUBLE PRECISION,
    "name_cash_loan_purpose" TEXT,
    "name_contract_status" TEXT,
    "days_decision" INTEGER,
    "name_payment_type" TEXT,
    "code_reject_reason" TEXT,
    "name_type_suite" TEXT,
    "name_client_type" TEXT,
    "name_goods_category" TEXT,
    "name_portfolio" TEXT,
    "name_product_type" TEXT,
    "channel_type" TEXT,
    "sellerplace_area" INTEGER,
    "name_seller_industry" TEXT,
    "cnt_payment" DOUBLE PRECISION,
    "name_yield_group" TEXT,
    "product_combination" TEXT,
    "days_first_drawing" DOUBLE PRECISION,
    "days_first_due" DOUBLE PRECISION,
    "days_last_due_1st_version" DOUBLE PRECISION,
    "days_last_due" DOUBLE PRECISION,
    "days_termination" DOUBLE PRECISION,
    "nflag_insured_on_approval" DOUBLE PRECISION
);

-- Table: transaction_types
CREATE TABLE "finance_kaggle"."transaction_types" (
    "transactiontypeid" INTEGER,
    "typename" TEXT
);

-- Table: transactions
CREATE TABLE "finance_kaggle"."transactions" (
    "transactionid" INTEGER,
    "accountoriginid" INTEGER,
    "accountdestinationid" INTEGER,
    "transactiontypeid" INTEGER,
    "amount" DOUBLE PRECISION,
    "transactiondate" TEXT,
    "branchid" INTEGER,
    "description" TEXT
);
