Skip to main content

Database Design

using

System : PostgreSQL node-module:

  • pg
  • sequelize : ORM

department

keydata typedescription
department_idSERIAL INTPK
department_nameVARCHAR(50)

Course

namedata typedescription
course_idSERIAL INTPK
course_nameVARCHAR(50)
course_teacherVARCHAR(50)可搭配 user(user_id)
course_contentVARCHAR(50)
course_timeVARCHAR(50)
creditINT
課程屬性 (course_type)VARCHAR(50)
討論版 (course_discuss)INT外鍵,連接討論區(討論課程編號)
考古題 (course_examination)VARCHAR(50)外鍵,連接考古題

考古題表 (exam table) [not finish]

namedata typedescription
exam_idINTPK course(course_id)
descriptionVARCHAR(200)
fileARRAYFK
imgARRAYFK

學年表 (year table) [input to user table]

名稱資料型態說明
Id (year_department)SERIAL INT主鍵
學年 (year_year)SMALLINT

畢業門檻 (graduation_requirement table) [to be microservice part]

名稱資料型態說明
id 系級SERIAL INT主鍵
必修SMALLINT
本系選修SMALLINT
外系選修SMALLINT
學年INT外鍵,連接 year(year_department)

討論表 (discuss board table) [討論區]

picture to be updated in next version

名稱資料型態說明
討論課程編號 (id)SERIAL INT主鍵
作者(author)INT外鍵 user(user_id)
討論標題 (topic)VARCHAR(50)
討論內容 (text_content)VARCHAR(50)
圖片網址TEXT[]
評分分數 (rate)INT
發布時間 (post_time)TIMESTAMP
留言使用者 (discuss_user)INT外鍵,連接 user(user_id)

圖片表 (image table) [討論版]

名稱資料型態說明
圖片編號 (image_id)SERIAL INT主鍵
圖片網址 (image_url)VARCHAR(255)

討論串表 (thread table) [討論版]

名稱資料型態說明
討論串編號 (thread_id)SERIAL INT主鍵
討論課程編號 (discuss_id)INT外鍵,連接 discuss(discuss_id)
討論內容 (thread_text)VARCHAR(255)
讚數 (likes)INT
編輯時間 (edit_time)TIMESTAMP

留言表 (comment table) [deprecate]

名稱資料型態說明
留言編號 (comment_id)SERIAL INT主鍵
討論課程編號 (discuss_id)INT外鍵,連接 discuss(discuss_id)
留言內容 (comment_text)VARCHAR(255)
留言使用者 (comment_user)INT外鍵,連接 user(user_id)
留言時間 (comment_time)TIMESTAMP