ER Diagram for Database Design - bounswe/bounswe2025group10 GitHub Wiki

This page presents the ER (Entity-Relationship) Diagram of our project, illustrating the structure of the database and the relationships between key entities.

The diagram serves as a reference for understanding how data is organized and connected throughout the system. It is useful for both development and documentation purposes, helping contributors and stakeholders grasp the overall data model at a glance.

swe_er_diagram Code:

@startuml
entity "Users" {
  * id : INT <<PK>>
  --
  username : VARCHAR
  password : VARCHAR
  profile_id : INT <<FK>>
}

entity "Profiles" {
  * id : INT <<PK>>
  --
  profile_image : VARCHAR
  bio : TEXT
}

entity "Posts" {
  * id : INT <<PK>>
  --
  creator_id : INT <<FK>>
  date : DATETIME
  text : TEXT
}

entity "Comments" {
  * id : INT <<PK>>
  --
  post_id : INT <<FK>>
  author_id : INT <<FK>>
  content : TEXT
  date : DATETIME
}

entity "Challenges" {
  * id : INT <<PK>>
  --
  title : VARCHAR
  description : TEXT
  target_amount : FLOAT
  current_progress : FLOAT
  reward_id : INT <<FK>>
  is_public : BOOLEAN
}

entity "UserChallenges" {
  * user_id : INT <<FK>>
  * challenge_id : INT <<FK>>
  --
  joined_date : DATETIME
}

entity "Achievements" {
  * id : INT <<PK>>
  --
  title : VARCHAR
  description : TEXT
}

entity "UserAchievements" {
  * user_id : INT <<FK>>
  * achievement_id : INT <<FK>>
  --
  earned_at : DATETIME
}

entity "WasteLogs" {
  * id : INT <<PK>>
  --
  user_id : INT <<FK>>
  challenge_id : INT <<FK>>
  type : VARCHAR
  date : DATETIME
  amount : FLOAT
}

entity "Tips" {
  * id : INT <<PK>>
  --
  text : TEXT
  like_count : INT
  dislike_count : INT
}

' Relationships
Users ||--|| Profiles : has
Users ||--o{ Posts : creates
Posts ||--o{ Comments : contains
Users ||--o{ Comments : writes
Users ||--o{ UserChallenges : participates
Challenges ||--o{ UserChallenges : includes
Challenges ||--|| Achievements : rewards
Users ||--o{ WasteLogs : logs
Challenges ||--o{ WasteLogs : related
Users ||--o{ UserAchievements : earns
Achievements ||--o{ UserAchievements : included
@enduml
⚠️ **GitHub.com Fallback** ⚠️