# AI日记应用数据库结构

## _User (系统预留表)
- **字段**
  - objectId (String) [PK]
  - username (String)
  - email (String)
  - authData (Object)
  - emailVerified (bool)
  - profilePicture (File)
  - lastActiveAt (Date)
  - createdAt/updatedAt (Date)

## Dynamic (动态表)
- **字段**
  - objectId (String) [PK]
  - content (String)
  - images (Array\<File\>)
  - location (GeoPoint)
  - mood (String)
  - tags (Array\<String\>)
  - isPublic (bool)
  - likeCount/commentCount/shareCount (Number)
  - createdAt/updatedAt (Date)
  - author (Pointer<_User>)
- **关系**
  - 1:n → _User (发布关系)
  - 1:n → Interaction (拥有关系)

## Interaction (互动表)
- **字段**
  - objectId (String) [PK]
  - type (String) `like|comment|share`
  - content (String)
  - createdAt/updatedAt (Date)
  - user (Pointer<_User>)
  - diary (Pointer<Dynamic>)
  - targetUser (Pointer<_User>)
- **关系**
  - n:1 → _User (发起用户)
  - n:1 → Moment (所属动态)
  - n:1 → _User (目标用户)

## 核心关系网
```mermaid
graph TD
    _User -- 发布 --> Dynamic
    _User -- 发起 --> Interaction
    Dynamic -- 拥有 --> Interaction
    Interaction -- 指向 --> _User(targetUser)