← blog 专题系列 · 2026-04-19

AI Interview 中的实体关系分析

梳理 AI Interview 项目的 PostgreSQL 数据模型:核心业务表、pgvector 向量存储的五种嵌入类型,以及 Mermaid 实体关系图与关联关系。

3 min read

存储业务实体和关系数据:

表/模块存储内容
User用户信息
Resume简历文本内容
Project项目经历
KnowledgeBase知识库元数据
InterviewSession面试会话记录
QAHistory问答历史
InterviewFeedback面试反馈

pgvector (向量数据)

存储嵌入向量用于语义检索:

向量类型来源用途
resume 向量简历文本根据技能点匹配简历
question 向量标准问题相似问题检索
standard_answer 向量标准答案答案评估参考
skill_point 向量技能点训练选题匹配
enterprise_knowledge 向量企业知识库最佳实践检索

实体关系图

erDiagram
    User {
        int id PK
        string uuid
        string name
        string email
        datetime created_at
    }
    Resume {
        int id PK
        int user_id FK
        string file_path
        text parsed_content
        datetime created_at
    }
    Project {
        int id PK
        int resume_id FK
        string name
        string repo_path
        text description
        datetime created_at
    }
    KnowledgeBase {
        int id PK
        int project_id FK
        string type
        string skill_point
        text content
        string embedding_id
        string responsibility_id
        string responsibility_text
        string question_id
        string session_id
        datetime created_at
    }
    InterviewSession {
        int id PK
        int user_id FK
        int resume_id FK
        string mode
        string feedback_mode
        string status
        datetime started_at
        datetime ended_at
    }
    QAHistory {
        int id PK
        int session_id FK
        string series
        int question_number
        text question
        text user_answer
        text standard_answer
        text feedback
        float deviation_score
        datetime created_at
    }
    InterviewFeedback {
        int id PK
        int session_id FK
        float overall_score
        json strengths
        json weaknesses
        json suggestions
        datetime created_at
    }
    ContextSnapshot {
        int id PK
        string session_id
        int version
        timestamp timestamp
        json compressed_summary
        datetime created_at
    }
    PGVector {
        string vector_type
        string storage
        string linked_entity
    }
    User ||--o{ Resume : "1:N 一个用户多份简历"
    Resume ||--o{ Project : "1:N 一份简历多个项目"
    Project ||--o{ KnowledgeBase : "1:N 一个项目多条知识"
    InterviewSession ||--o{ QAHistory : "1:N 一个会话多条问答记录"
    InterviewSession ||--o{ InterviewFeedback : "1:N"
    KnowledgeBase }o..o{ PGVector : "embedding_id"

关联关系

graph TD
    KB["KnowledgeBase"] -->|"embedding_id"| PG["pgvector.embeddings"]
    KB -->|"skill_point"| EM["Embedding Model"]
    EM --> VR["向量检索"]
    VR --> CS["语义相似度搜索 (cosine similarity)"]

graph TD
    Upload["简历上传"] --> Res["Resume (PostgreSQL)"]
    Res --> PC["parsed_content"]
    PC --> EM["Embedding Model"]
    EM --> PG["pgvector"]
    Res --> Proj["Project"]
    Proj --> KB["KnowledgeBase"]
    KB --> Q["面试问题 → 检索最相似的技能点"]
    Q --> Ans["返回匹配的标准答案/问题"]
    SR["检索匹配"] <-->|"skill_point"| KB

关键关系:

  • User 1:N Resume - 一个用户多份简历
  • Resume 1:N Project - 一份简历多个项目
  • Project 1:N KnowledgeBase - 一个项目多条知识
  • KnowledgeBase.embedding_id → pgvector - 知识库通过ID关联向量
  • InterviewSession 1:N QAHistory - 一个会话多条问答记录

Sources

No external sources for this entry.

Related