Data Model — All Core Objects¶
Star Schema: 2 Fact Snapshot + 6 Dimension tables (SCD1/SCD2)
ERD Overview¶
Hướng dẫn đọc diagram
- Bảng màu xanh bên trái: 2 bảng Fact (Loan & Deposit)
- Bảng bên phải: 6 bảng Dimension
- Mũi tên: Fact → Dimension (many-to-one)
- Click vào tên bảng trong mục lục bên dưới để xem chi tiết
erDiagram
FACT_LOAN_ARR {
SK calendar_date_dim_id PK
SK loan_arr_dim_id PK
Text scenario_code
SK customer_dim_id FK
SK rel_org_unit_dim_id FK
SK currency_dim_id FK
SK product_dim_id FK
Amt closing_balance_fcy
Amt disbursement_mtd_fcy
Amt debt_collection_mtd_fcy
}
FACT_DEPOSIT_ARR {
SK calendar_date_dim_id PK
SK deposit_arr_dim_id PK
SK customer_dim_id FK
SK rel_org_unit_dim_id FK
SK currency_dim_id FK
SK product_dim_id FK
Amt closing_balance_fcy
}
DIM_CALENDAR_DATE {
SK calendar_date_dim_id PK
Date calendar_date
Text calendar_year
Text calendar_quarter
Text calendar_month
Text day_of_week
Ind holiday_flag
}
DIM_CUSTOMER {
SK customer_dim_id PK
SK customer_id
Text customer_code
Text full_name
CV customer_type_code
CV customer_segment_code
CV life_cycle_status_code
}
DIM_ORG_UNIT {
SK org_unit_dim_id PK
Text org_unit_code
CV org_unit_type_code
Text org_unit_name
CV region_code
}
DIM_CURRENCY {
SK currency_dim_id PK
Text currency_code
Text currency_name
Ind base_currency_flag
}
DIM_PRODUCT {
SK product_dim_id PK
Text product_code
Text product_name
}
DIM_LOAN_ARR {
SK loan_arr_dim_id PK
Text loan_arr_code
Text account_number
CV loan_term_type_code
Date disbursement_date
Date maturity_date
Rate interest_rate_pct
}
DIM_DEPOSIT_ARR {
SK deposit_arr_dim_id PK
Text deposit_arr_code
Text account_number
Rate interest_rate_pct
Text term
Date maturity_date
}
FACT_LOAN_ARR }o--|| DIM_CALENDAR_DATE : "data_date"
FACT_LOAN_ARR }o--|| DIM_LOAN_ARR : "loan"
FACT_LOAN_ARR }o--|| DIM_CUSTOMER : "customer"
FACT_LOAN_ARR }o--|| DIM_ORG_UNIT : "branch"
FACT_LOAN_ARR }o--|| DIM_CURRENCY : "currency"
FACT_LOAN_ARR }o--|| DIM_PRODUCT : "product"
FACT_DEPOSIT_ARR }o--|| DIM_CALENDAR_DATE : "data_date"
FACT_DEPOSIT_ARR }o--|| DIM_DEPOSIT_ARR : "deposit"
FACT_DEPOSIT_ARR }o--|| DIM_CUSTOMER : "customer"
FACT_DEPOSIT_ARR }o--|| DIM_ORG_UNIT : "branch"
FACT_DEPOSIT_ARR }o--|| DIM_CURRENCY : "currency"
FACT_DEPOSIT_ARR }o--|| DIM_PRODUCT : "product"
Ký hiệu kiểu dữ liệu¶
| Viết tắt | Kiểu đầy đủ | Ý nghĩa |
|---|---|---|
| SK | Surrogate Key | Khóa tự sinh |
| Text | Text | Chuỗi văn bản |
| CV | Classification Value | Giá trị phân loại (code) |
| Date | Date | Ngày tháng |
| Ind | Indicator | Cờ đánh dấu (Y/N, 0/1) |
| Rate | Interest Rate | Lãi suất |
| Amt | Currency Amount | Số tiền |
| Cnt | Small Counter | Số đếm nhỏ |
Fact Tables¶
Loan Arrangement Fact (Fact Snapshot)¶
Fact chi tiết cho hợp đồng tiền vay
| Cột | Kiểu | Key | Ref → | Mô tả |
|---|---|---|---|---|
| Calendar Date Dimension Id | Surrogate Key | PK | DIM_CALENDAR_DATE | Ngày chạy dữ liệu |
| Loan Arrangement Dimension Id | Surrogate Key | PK | DIM_LOAN_ARR | Hợp đồng tiền vay |
| Scenario Code | Text | Mã scenario (ACTUAL, BACKDATE) | ||
| Customer Dimension Id | Surrogate Key | FK | DIM_CUSTOMER | Khách hàng |
| Relationship Organization Unit Dimension Id | Surrogate Key | FK | DIM_ORG_UNIT | Chi nhánh quản lý |
| Currency Dimension Id | Surrogate Key | FK | DIM_CURRENCY | Loại tiền |
| Product Dimension Id | Surrogate Key | FK | DIM_PRODUCT | Sản phẩm |
| Closing Balance FCY | Currency Amount | Số dư nguyên tệ | ||
| Total Disbursement Amount MTD FCY | Currency Amount | Doanh số giải ngân từ đầu tháng (nguyên tệ) | ||
| Total Debt Collection Amount MTD FCY | Currency Amount | Doanh số thu nợ từ đầu tháng (nguyên tệ) |
Deposit Arrangement Fact (Fact Snapshot)¶
Fact chi tiết cho hợp đồng tiền gửi
| Cột | Kiểu | Key | Ref → | Mô tả |
|---|---|---|---|---|
| Calendar Date Dimension Id | Surrogate Key | PK | DIM_CALENDAR_DATE | Ngày chạy dữ liệu |
| Deposit Arrangement Dimension Id | Surrogate Key | PK | DIM_DEPOSIT_ARR | Hợp đồng tiền gửi |
| Customer Dimension Id | Surrogate Key | FK | DIM_CUSTOMER | Khách hàng |
| Relationship Organization Unit Dimension Id | Surrogate Key | FK | DIM_ORG_UNIT | Chi nhánh quản lý |
| Currency Dimension Id | Surrogate Key | FK | DIM_CURRENCY | Loại tiền |
| Product Dimension Id | Surrogate Key | FK | DIM_PRODUCT | Sản phẩm |
| Closing Balance FCY | Currency Amount | Số dư nguyên tệ |
Dimension Tables¶
Product Dimension (SCD2)¶
Dim Danh mục sản phẩm
| Cột | Kiểu | PK | Mô tả |
|---|---|---|---|
| Product Dimension Id | Surrogate Key | ✅ | Id tự sinh cho Dimension |
| Product Id | Surrogate Key | Mã sản phẩm (Id trên Data Model) | |
| Product Code | Text | Mã sản phẩm | |
| Product Name | Text | Tên sản phẩm | |
| Source System Code | Classification Value | Mã nguồn dữ liệu |
Currency Dimension (SCD2)¶
Dim Danh mục loại tiền
| Cột | Kiểu | PK | Mô tả |
|---|---|---|---|
| Currency Dimension Id | Surrogate Key | ✅ | Id tự sinh cho Dimension |
| Currency Code | Text | Mã loại tiền | |
| Base Currency Flag | Indicator | Cờ đánh dấu loại tiền chính (VND) | |
| Currency Name | Text | Tên loại tiền | |
| Source System Code | Classification Value | Mã nguồn dữ liệu |
Organization Unit Dimension (SCD2)¶
Dim Thông tin phòng ban, chi nhánh
| Cột | Kiểu | PK | Mô tả |
|---|---|---|---|
| Organization Unit Dimension Id | Surrogate Key | ✅ | Id tự sinh cho Dimension |
| Organization Unit Id | Surrogate Key | Id của Organization Unit trên Data Model | |
| Organization Unit Code | Text | Mã của Organization Unit | |
| Organization Unit Type Code | Classification Value | Phân loại (Chi nhánh, Phòng ban) | |
| Organization Unit Name | Text | Tên của Organization | |
| Region Code | Classification Value | Vùng của chi nhánh |
Customer Dimension (SCD2)¶
Dim Thông tin khách hàng
| Cột | Kiểu | PK | Mô tả |
|---|---|---|---|
| Customer Dimension Id | Surrogate Key | ✅ | Id tự sinh cho Dimension |
| Customer Id | Surrogate Key | Id của Customer trên Data Model | |
| Customer Code | Text | Mã khách hàng | |
| Full Name | Text | Tên khách hàng | |
| Birth Date | Date | Ngày sinh | |
| Gender Code | Classification Value | Giới tính | |
| Identification Number | Text | CCCD / ĐKKD | |
| Customer Type Code | Classification Value | Loại khách hàng | |
| Customer Segment Code | Classification Value | Phân khúc khách hàng | |
| Line of Business Code | Classification Value | Khối kinh doanh (cá nhân, doanh nghiệp) | |
| Customer Life Cycle Status Code | Classification Value | Trạng thái (Active, Inactive) | |
| End Customer Date | Date | Ngày đóng khách hàng | |
| Initiated Date | Date | Thời điểm tạo khách hàng | |
| Updated Date | Date | Thời điểm cập nhật khách hàng | |
| Source System Code | Classification Value | Mã nguồn dữ liệu |
Calendar Date Dimension (SCD1)¶
Dim ngày dữ liệu
| Cột | Kiểu | PK | Mô tả |
|---|---|---|---|
| Calendar Date Dimension Id | Surrogate Key | ✅ | Id tự sinh |
| Calendar Date | Date | Ngày | |
| Calendar Year | Text | Năm | |
| Calendar Quarter | Text | Quý | |
| Calendar Month | Text | Tháng | |
| Calendar Day | Text | Ngày trong tháng | |
| Day Of Week | Text | Thứ trong tuần | |
| Holiday Flag | Indicator | Cờ đánh dấu ngày nghỉ | |
| Source System Code | Text | Mã nguồn dữ liệu |
Deposit Arrangement Dimension (SCD2)¶
Dim Thông tin các hợp đồng tiền gửi
| Cột | Kiểu | PK | Mô tả |
|---|---|---|---|
| Deposit Arrangement Dimension Id | Surrogate Key | ✅ | Id tự sinh cho Dimension |
| Deposit Arrangement Id | Surrogate Key | Id trên Data Model | |
| Deposit Arrangement Code | Text | Mã hợp đồng tiền gửi | |
| Account Number | Text | Số tài khoản | |
| Effective Interest Rate Percentage | Interest Rate | Lãi suất | |
| Term | Text | Kỳ hạn | |
| Maturity Date | Date | Ngày đáo hạn | |
| Life Cycle Status Code | Classification Value | Trạng thái (Active, Closed) | |
| Organization Unit Code | Text | Chi nhánh của hợp đồng | |
| Customer Code | Text | Mã khách hàng | |
| Product Code | Text | Mã sản phẩm | |
| Source System Code | Classification Value | Mã nguồn dữ liệu |
Loan Arrangement Dimension (SCD2)¶
Dim Thông tin các hợp đồng tiền vay
| Cột | Kiểu | PK | Mô tả |
|---|---|---|---|
| Loan Arrangement Dimension Id | Surrogate Key | ✅ | Id tự sinh cho Dimension |
| Loan Arrangement Id | Surrogate Key | Id trên Data Model | |
| Loan Arrangement Code | Text | Mã khoản vay | |
| Account Number | Text | Số tài khoản | |
| Loan Term Type Code | Classification Value | Loại kỳ hạn (Short/Medium/LongTerm) | |
| Disbursement Date | Date | Ngày giải ngân | |
| Maturity Date | Date | Ngày đáo hạn | |
| Term in Months | Small Counter | Kỳ hạn theo tháng | |
| Effective Interest Rate Percentage | Interest Rate | Lãi suất | |
| Interest Variance Type Code | Classification Value | Loại lãi suất (Fixed, Floating) | |
| Payment Frequency Code | Classification Value | Tần suất trả (Monthly, Quarterly) | |
| Relationship Organization Unit Code | Text | Mã chi nhánh quản lý | |
| Customer Code | Text | Mã khách hàng | |
| Product Code | Text | Mã sản phẩm vay | |
| Source System Code | Classification Value | Mã nguồn dữ liệu |