Try   HackMD

資料庫期末專案

  • 課程名稱:資料庫系統
  • 授課老師:張雅惠老師
  • 修課學期:112-1


Introduction


功能介紹

此系統是提供給資工系的學生互相交流與學習,使用者可以註冊並登入此系統,登入後即可開始上傳、修改、刪除筆記以及程式練習題目,就算沒有帳號的使用者也可以瀏覽或查詢別人分享的筆記以及程式練習題目。


ER-Diagram

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

  • note 跟 code_practice 的 id,是指他們各自的文章ID,也是他們的 primary key
  • title、description、topic、course_name、url、userid,分別指他們各自的標題、描述、主題、相關課程、網址、作者ID(foreign key)

表格定義與正規型式分析

Tables

  • user (userid, password, username)
  • note (id, title, description, topic, course_name, url, userid)
  • code_practice (id, title, description, topic, course_name, url, userid)

Table user

CREATE TABLE `user` ( `userid` varchar(50) NOT NULL, `password` varchar(1024) NOT NULL, `username` varchar(50) NOT NULL, PRIMARY KEY(`userid`) );

Normalization
F={
  userid→password
  userid→username
}

此表格符合3NF和BCNF
  1. userid代表一個特定的user,所以可以決定唯一的username。
  2. userid代表一個特定的user,且為一個特定的帳號,所以可以決定唯一的password。
  3. userid是一個candidate key

Table note

CREATE TABLE `note` ( `id` int(11) NOT NULL AUTO_INCREMENT, `title` varchar(64) NOT NULL, `description` varchar(1024) DEFAULT NULL, `topic` varchar(256) DEFAULT NULL, `course_name` varchar(64) DEFAULT NULL, `url` varchar(2048) NOT NULL, `userid` varchar(50) NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY (`userid`) REFERENCES `user` (`userid`) ON UPDATE CASCADE; );

Normalization
F={
  id→title
  id→description
  id→topic
  id→course_name
  id→url
  id→userid
}

此表格符合3NF和BCNF
  1. id代表一個特定的noteID,所以可以決定唯一的title、description、topic、course_name、url、userid
  2. id是一個candidate key

Table code_practice

CREATE TABLE `code_practice` ( `id` int(11) NOT NULL AUTO_INCREMENT, `title` varchar(64) NOT NULL, `description` varchar(1024) DEFAULT NULL, `topic` varchar(256) DEFAULT NULL, `course_name` varchar(64) DEFAULT NULL, `url` varchar(2048) NOT NULL, `userid` varchar(50) NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY (`userid`) REFERENCES `user` (`userid`) ON UPDATE CASCADE; );

Normalization
F={
  id→title
  id→description
  id→topic
  id→course_name
  id→url
  id→userid
}

此表格符合3NF和BCNF
  1. id代表一個特定的noteID,所以可以決定唯一的title、description、topic、course_name、url、userid。
  2. id是一個candidate key