192 lines
6.2 KiB
Markdown
192 lines
6.2 KiB
Markdown
# FORMAT
|
|
|
|
# Title: Database Schema
|
|
|
|
# Database Type: PostgreSQL
|
|
|
|
# Core Entities
|
|
|
|
## Profile
|
|
* **Description**: Lưu thông tin người tham gia
|
|
* **Fields**:
|
|
* `id` (UUID, PRIMARY KEY): Unique identifier
|
|
* `fullName` (TEXT): Tên đầy đủ người dùng
|
|
* `dateOfBirth` (DATE): Ngày sinh
|
|
* `gender` (TEXT): Giới tính
|
|
* `preferredGender` (TEXT): Giới tính mong muốn
|
|
* `phoneNumber` (TEXT): Số điện thoại
|
|
* `email` (TEXT): Email
|
|
* `facebookLink` (TEXT): Link Facebook
|
|
* `photoReference` (TEXT): Reference to stored photo
|
|
* `location` (TEXT): Khu vực
|
|
* `team` (TEXT): Team choice
|
|
* `hobbies` (TEXT[]): Sở thích
|
|
* `thingsNotTried` (TEXT): Thứ chưa thử qua
|
|
* `hopesForPartner` (TEXT): Mong muốn đối với đối tác
|
|
* `dealbreakers` (TEXT): Ranh giới
|
|
* `messageToPartner` (TEXT): Thông điệp gửi đối tác
|
|
* `zodiacSign` (TEXT): Cung hoàng đạo
|
|
* `accessCode` (TEXT): Code truy cập kết quả
|
|
* `personalLink` (TEXT): Link cá nhân
|
|
* `acceptedTerms` (BOOLEAN): Chấp nhận điều khoản
|
|
* `registrationTimestamp` (TIMESTAMP): Thời điểm đăng ký
|
|
* `status` (TEXT): Trạng thái
|
|
* `isLuckyWinner` (BOOLEAN): Có trúng thưởng
|
|
* `createdAt` (TIMESTAMP): Thời điểm tạo
|
|
* `updatedAt` (TIMESTAMP): Thời điểm cập nhật
|
|
|
|
## MatchOutcome
|
|
* **Description**: Lưu kết quả matching cho một Profile
|
|
* **Fields**:
|
|
* `id` (UUID, PRIMARY KEY): Unique identifier
|
|
* `profileId` (UUID, FK): ID hồ sơ
|
|
* `potentialMatchProfileIds` (UUID[]): Danh sách ID 3 đối tượng phù hợp
|
|
* `matchScores` (JSON): Điểm match
|
|
* `status` (TEXT): Trạng thái
|
|
* `selectedProfileId` (UUID): ID hồ sơ được chọn
|
|
* `generationTimestamp` (TIMESTAMP): Thời điểm tạo kết quả
|
|
* `accessedTimestamp` (TIMESTAMP): Thời điểm truy cập
|
|
* `selectionTimestamp` (TIMESTAMP): Thời điểm chọn
|
|
* `createdAt` (TIMESTAMP): Thời điểm tạo
|
|
* `updatedAt` (TIMESTAMP): Thời điểm cập nhật
|
|
|
|
## GiftAllocation
|
|
* **Description**: Ghi nhận việc phân bổ quà tặng
|
|
* **Fields**:
|
|
* `id` (UUID, PRIMARY KEY): Unique identifier
|
|
* `profileId` (UUID, FK): ID hồ sơ
|
|
* `giftId` (UUID, FK): ID quà
|
|
* `allocationTimestamp` (TIMESTAMP): Thời điểm phân bổ
|
|
* `notificationStatus` (TEXT): Trạng thái thông báo
|
|
* `notificationSentTimestamp` (TIMESTAMP): Thời điểm gửi thông báo
|
|
* `createdAt` (TIMESTAMP): Thời điểm tạo
|
|
* `updatedAt` (TIMESTAMP): Thời điểm cập nhật
|
|
|
|
## Gift
|
|
* **Description**: Lưu thông tin các loại quà tặng
|
|
* **Fields**:
|
|
* `id` (UUID, PRIMARY KEY): Unique identifier
|
|
* `name` (TEXT): Tên quà
|
|
* `description` (TEXT): Mô tả
|
|
* `imageUrl` (TEXT): URL hình ảnh
|
|
* `isActive` (BOOLEAN): Trạng thái hoạt động
|
|
* `createdAt` (TIMESTAMP): Thời điểm tạo
|
|
* `updatedAt` (TIMESTAMP): Thời điểm cập nhật
|
|
|
|
# Indexes
|
|
* `profiles_email_idx`: Index trên trường email của Profile
|
|
* `profiles_access_code_idx`: Index trên trường accessCode của Profile
|
|
* `match_outcomes_profile_id_idx`: Index trên trường profileId của MatchOutcome
|
|
|
|
# DATA SCHEMA AND STRUCTURES
|
|
|
|
## 1. Database Schema
|
|
|
|
### Table: [Table Name]
|
|
#### Description: [Brief description of the table's purpose]
|
|
#### Columns:
|
|
* **[Column Name]** (`[Data Type]`): [Brief description]. Constraints: `[Constraint(s)]`. [PK/FK (references Table(Column))] [Index (Type)]
|
|
#### Relationships:
|
|
* `[Table Name]` `[Relationship Type]` `[Another Table Name]` (on `[Column Name]` -> `[Another Table Name].[Column Name]`)
|
|
#### Indexes:
|
|
* `[Index Name]` on `[Column(s)]` (`[Index Type]`)
|
|
|
|
## 2. Generic Data Declarations
|
|
|
|
### 2.1. [Data Structure Name]
|
|
#### Description: [Brief description of the purpose of this data structure.]
|
|
#### Fields:
|
|
* **[Field Name]** (`[Data Type]`): [Brief description of the field]. [Constraints/Rules]
|
|
#### Example (Optional):
|
|
```json
|
|
{
|
|
"[field name]": "[example value]",
|
|
"[another field]": "[example value]"
|
|
}
|
|
```
|
|
|
|
## 3. Application-Specific Data Structures
|
|
|
|
### 3.1. Profile Aggregate
|
|
#### Description: Aggregate for storing user profile information.
|
|
#### Fields:
|
|
```go
|
|
type Profile struct {
|
|
ID string
|
|
FullName string
|
|
DateOfBirth time.Time
|
|
Gender string
|
|
PreferredGender string
|
|
PhoneNumber string
|
|
Email string
|
|
FacebookLink string
|
|
PhotoReference string
|
|
Location string
|
|
Team string
|
|
Hobbies []string
|
|
ThingsNotTried []string
|
|
HopesForPartner string
|
|
Dealbreakers string
|
|
MessageToPartner string
|
|
ZodiacSign string
|
|
AccessCode string
|
|
PersonalLink string
|
|
AcceptedTerms bool
|
|
RegistrationTimestamp time.Time
|
|
Status string
|
|
IsLuckyWinner bool
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
}
|
|
```
|
|
|
|
### 3.2. MatchOutcome Aggregate
|
|
#### Description: Aggregate for storing match outcome information.
|
|
#### Fields:
|
|
```go
|
|
type MatchOutcome struct {
|
|
ID string
|
|
ProfileID string
|
|
PotentialMatchProfileIDs []string
|
|
MatchScores map[string]float64 // Optional
|
|
Status string
|
|
SelectedProfileID string
|
|
GenerationTimestamp time.Time
|
|
AccessedTimestamp time.Time
|
|
SelectionTimestamp time.Time
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
}
|
|
```
|
|
|
|
### 3.3. GiftAllocation Aggregate
|
|
#### Description: Aggregate for storing gift allocation information.
|
|
#### Fields:
|
|
```go
|
|
type GiftAllocation struct {
|
|
ID string
|
|
ProfileID string
|
|
GiftID string
|
|
AllocationTimestamp time.Time
|
|
NotificationStatus string
|
|
NotificationSentTimestamp time.Time
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
}
|
|
```
|
|
|
|
### 3.4. Gift Aggregate
|
|
#### Description: Aggregate for storing gift information.
|
|
#### Fields:
|
|
```go
|
|
type Gift struct {
|
|
ID string
|
|
Name string
|
|
Description string
|
|
ImageURL string // Optional
|
|
IsActive bool
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
}
|
|
```
|
|
--- |