【中國大學生電腦大賽三等獎】冬奧會智慧分析與預測可視化平台-資料庫設計(二)
- 2022 年 10 月 8 日
- 筆記
- 冬奧會智慧分析與預測可視化平台
一 前言
此項目為冬奧會智慧分析與預測可視化平台,這個項目是用於參加中國大學生電腦設計大賽-資訊可視化設計賽道的項目,最終獲得國賽三等獎的成績。現在主要介紹一下本項目的資料庫設計。
二 資料庫選擇
本項目選擇的資料庫為MySQL資料庫。
2.1 MySQL資料庫
MySQL是一個關係型資料庫管理系統,由瑞典MySQL AB 公司開發,屬於 Oracle 旗下產品。MySQL 是最流行的關係型資料庫管理系統之一,在 WEB 應用方面,MySQL是最好的 RDBMS (Relational Database Management System,關係資料庫管理系統) 應用軟體之一。
MySQL是一種關係型資料庫管理系統,關係資料庫將數據保存在不同的表中,而不是將所有數據放在一個大倉庫內,這樣就增加了速度並提高了靈活性。
MySQL所使用的 SQL 語言是用於訪問資料庫的最常用標準化語言。MySQL 軟體採用了雙授權政策,分為社區版和商業版,由於其體積小、速度快、總體擁有成本低,尤其是開放源碼這一特點,一般中小型和大型網站的開發都選擇 MySQL 作為網站資料庫。
2.2 MySQL優點
1. MySQL使用 C和 C++編寫,並使用了多種編譯器進行測試,保證了源程式碼的可移植性。
2.支援 AIX、FreeBSD、HP-UX、Linux、Mac OS、NovellNetware、OpenBSD、OS/2 Wrap、Solaris、Windows等多種作業系統。
3.為多種程式語言提供了 API。這些程式語言包括 C、C++、Python、Java、Perl、PHP、Eiffel、Ruby,.NET和 Tcl 等。
4.支援多執行緒,充分利用 CPU 資源。
5.優化的 SQL查詢演算法,有效地提高查詢速度。
6.既能夠作為一個單獨的應用程式應用在客戶端伺服器網路環境中,也能夠作為一個庫而嵌入到其他的軟體中。
7.提供多語言支援,常見的編碼如中文的 GB 2312、BIG5,日文的 Shift_JIS等都可以用作數據表名和數據列名。
8.提供 TCP/IP、ODBC 和 JDBC等多種資料庫連接途徑。
9.提供用於管理、檢查、優化資料庫操作的管理工具。
10.支援大型的資料庫。可以處理擁有上千萬條記錄的大型資料庫。
11.支援多種存儲引擎。
12.MySQL 是開源的,所以你不需要支付額外的費用。
13.MySQL 使用標準的 SQL數據語言形式。
14.MySQL 對 PHP 有很好的支援,PHP是比較流行的 Web 開發語言。
15.MySQL是可以訂製的,採用了 GPL協議,你可以修改源碼來開發自己的 MySQL 系統。
三 資料庫設計
數據來源
2022北京冬奧組委官網、國際奧林匹克官網等網站收集獎牌及影片數據,百度百科收集運動員個人資訊數據,聚會數據網收集預測因素數據。
數據表
此項目資料庫設計共包含10張數據表,分別為
- 用戶資訊表
- 歷屆冬奧會國家參賽人數表
- 歷屆冬奧會國家獲得獎牌總表
- 歷屆冬奧會國家獲得獎牌比賽項目表
- 獲得獎牌的運動員資訊表
- 具體比賽項目獲得獎牌的運動員表
- 比賽項目資訊表
- 比賽項目精彩影片表歷屆冬奧會
- 下屆冬奧會預測因素表
- 下屆冬奧會預測獎牌表。
3.1 用戶資訊表

package models
import "time"
type User struct {
ID int `json:"id" gorm:"column:id"`
Email string `json:"email" gorm:"column:email"`
Password string `json:"password" gorm:"column:password"`
CreateTime time.Time `json:"create_time" gorm:"column:create_time"`
IsValid string `json:"is_valid" gorm:"column:is_valid"`
}
3.2 歷屆冬奧會國家參賽人數表

package models
type CountryHuman struct {
ID int `json:"id" gorm:"column:id"`
Noc string `json:"noc" gorm:"column:noc"`
Country string `json:"country" gorm:"column:country"`
CountryMap string `json:"country_map" gorm:"column:country_map"`
Men int `json:"men" gorm:"column:men"`
Women int `json:"women" gorm:"column:women"`
Total int `json:"total" gorm:"column:total"`
Year int `json:"year" gorm:"column:year"`
}
3.3 歷屆冬奧會國家獲得獎牌總表

package models
type CountryMedals struct {
ID int `json:"id" gorm:"column:id"`
Country string `json:"country" gorm:"column:country"`
Noc string `json:"noc" gorm:"column:noc"`
Gold int `json:"gold" gorm:"column:gold"`
Silver int `json:"silver" gorm:"column:silver"`
Bronze int `json:"bronze" gorm:"column:bronze"`
Total int `json:"total" gorm:"column:total"`
Year int `json:"year" gorm:"column:year"`
}
3.4 歷屆冬奧會國家獲得獎牌比賽項目表

package models
type CountryEventMedals struct {
ID int `json:"id" gorm:"column:id"`
Country string `json:"country" gorm:"column:country"`
Noc string `json:"noc" gorm:"column:noc"`
Gold int `json:"gold" gorm:"column:gold"`
Silver int `json:"silver" gorm:"column:silver"`
Bronze int `json:"bronze" gorm:"column:bronze"`
Total int `json:"total" gorm:"column:total"`
Sport string `json:"sport" gorm:"column:sport"`
Year int `json:"year" gorm:"column:year"`
}
3.5 獲得獎牌的運動員資訊表

package models
type AthleteInformation struct {
ID int `json:"id" gorm:"column:id"`
Name string `json:"name" gorm:"column:name"`
Information string `json:"information" gorm:"column:information"`
Prize string `json:"prize" gorm:"column:prize"`
Picture string `json:"picture" gorm:"column:picture"`
}
3.6 具體比賽項目獲得獎牌的運動員表

package models
type AthletesMedals struct {
ID int `json:"id" gorm:"column:id"`
Event string `json:"event" gorm:"column:event"`
Gold string `json:"gold" gorm:"column:gold"`
GoldNoc string `json:"gold_noc" gorm:"column:gold_noc"`
Silver string `json:"silver" gorm:"column:silver"`
SilverNoc string `json:"silver_noc" gorm:"column:silver_noc"`
Bronze string `json:"bronze" gorm:"column:bronze"`
BronzeNoc string `json:"bronze_noc" gorm:"column:bronze_noc"`
Sport string `json:"sport" gorm:"column:sport"`
Year int `json:"year" gorm:"column:year"`
}
3.7 比賽項目資訊表

package models
type SportDescription struct {
ID int `json:"id" gorm:"column:id"`
Sport string `json:"sport" gorm:"column:sport"`
Description string `json:"description" gorm:"column:description"`
}
3.8 比賽項目精彩影片表歷屆冬奧會

package models
type SportVideo struct {
ID int `json:"id" gorm:"column:id"`
Name string `json:"name" gorm:"column:name"`
Describe1 string `json:"describe1" gorm:"column:describe1"`
Video1 string `json:"video1" gorm:"column:video1"`
Img1 string `json:"img1" gorm:"column:img1"`
Describe2 string `json:"describe2" gorm:"column:describe2"`
Video2 string `json:"video2" gorm:"column:video2"`
Img2 string `json:"img2" gorm:"column:img2"`
Describe3 string `json:"describe3" gorm:"column:describe3"`
Video3 string `json:"video3" gorm:"column:video3"`
Img3 string `json:"img3" gorm:"column:img3"`
Year int `json:"year" gorm:"column:year"`
}
3.9 下屆冬奧會預測因素表

package models
type Predict struct {
ID int `json:"id" gorm:"column:id"`
Name string `json:"name" gorm:"column:name"`
Noc string `json:"noc" gorm:"column:noc"`
Men int `json:"men" gorm:"column:men"`
Women int `json:"women" gorm:"column:women"`
IsHome int `json:"is_home" gorm:"column:is_home"`
HumanGdp float64 `json:"human_gdp" gorm:"column:human_gdp"`
Gdp float64 `json:"gdp" gorm:"column:gdp"`
HumanTotal int `json:"human_total" gorm:"column:human_total"`
SocialSystem int `json:"social_system" gorm:"column:social_system"`
GoldRank int `json:"gold_rank" gorm:"column:gold_rank"`
SilverRank int `json:"silver_rank" gorm:"column:silver_rank"`
BronzeRank int `json:"bronze_rank" gorm:"column:bronze_rank"`
GoldPercent float64 `json:"gold_percent" gorm:"column:gold_percent"`
SilverPercent float64 `json:"silver_percent" gorm:"column:silver_percent"`
BronzePercent float64 `json:"bronze_percent" gorm:"column:bronze_percent"`
GoldCount int `json:"gold_count" gorm:"column:gold_count"`
SilverCount int `json:"silver_count" gorm:"column:silver_count"`
BronzeCount int `json:"bronze_count" gorm:"column:bronze_count"`
Year int `json:"year" gorm:"column:year"`
}
3.10 下屆冬奧會預測獎牌表

package models
type PredictResult struct {
ID int `json:"id" gorm:"column:id"`
CountryName string `json:"country_name" gorm:"column:country_name"`
GoldCount int `json:"gold_count" gorm:"column:gold_count"`
SilverCount int `json:"silver_count" gorm:"column:silver_count"`
BronzeCount int `json:"bronze_count" gorm:"column:bronze_count"`
}
四 總結
以上就是冬奧會智慧分析與預測可視化平台項目的資料庫的具體設計啦,資料庫設計中可能會有一些不足,請大家多多批評指正。
本專欄還會繼續的更新,希望大家能夠多多關注部落客的文章,感謝大家的觀看。

