---
config:
    layout: elk
---
erDiagram
    BlogUser {
        int id PK
        string username
        string email
        string nickname
        datetime creation_time
        datetime last_modify_time
        string source
    }
    
    Article {
        int id PK
        string title
        text body
        datetime pub_time
        char status
        char comment_status
        char type
        int views
        int author_id FK
        int article_order
        boolean show_toc
        int category_id FK
    }
    
    Category {
        int id PK
        string name
        int parent_category_id FK
        string slug
        int index
    }
    
    Tag {
        int id PK
        string name
        string slug
    }
    
    Comment {
        int id PK
        text body
        datetime creation_time
        datetime last_modify_time
        int author_id FK
        int article_id FK
        int parent_comment_id FK
        boolean is_enable
    }
    
    OAuthUser {
        int id PK
        int author_id FK
        string openid
        string nickname
        string token
        string picture
        string type
        string email
        text metadata
        datetime creation_time
        datetime last_modify_time
    }
    
    OAuthConfig {
        int id PK
        string type
        string appkey
        string appsecret
        string callback_url
        boolean is_enable
        datetime creation_time
        datetime last_modify_time
    }
    
    BlogSettings {
        int id PK
        string site_name
        text site_description
        text site_seo_description
        text site_keywords
        int article_sub_length
        int sidebar_article_count
        int sidebar_comment_count
        int article_comment_count
        boolean show_google_adsense
        text google_adsense_codes
        boolean open_site_comment
        text global_header
        text global_footer
        string beian_code
        text analytics_code
        boolean show_gongan_code
        text gongan_beiancode
        boolean comment_need_review
    }
    
    SideBar {
        int id PK
        string name
        text content
        int sequence
        boolean is_enable
        datetime creation_time
        datetime last_mod_time
    }
    
    Links {
        int id PK
        string name
        string link
        int sequence
        boolean is_enable
        char show_type
        datetime creation_time
        datetime last_mod_time
    }
    
    OwnTrackLog {
        int id PK
        string tid
        float lat
        float lon
        datetime creation_time
    }
    
    commands {
        int id PK
        string title
        string command
        string describe
        datetime creation_time
        datetime last_modify_time
    }
    
    EmailSendLog {
        int id PK
        string emailto
        string title
        text content
        boolean send_result
        datetime creation_time
    }

    BlogUser ||--o{ Article : "作者发表"
    BlogUser ||--o{ Comment : "用户评论"
    BlogUser ||--o{ OAuthUser : "关联第三方账号"
    
    Article ||--o{ Comment : "文章拥有评论"
    Article }o--|| Category : "属于分类"
    Article }o--o{ Tag : "包含标签"
    
    Category ||--o{ Category : "父分类"
    
    Comment ||--o{ Comment : "父评论"
    
    OAuthUser }o--|| OAuthConfig : "使用配置"