--- tags: NCTU-courses --- # Database Project ###### tags: `Database` `Project` ## Group 06 - 張家誠 - 戴靖婷 - 褚又嘉 - 郭乃恩 ## Data - The description of your data - introduction of the data - 國人出境的資料統計 - 外國人來臺的資料統計 - 匯率狀況 - what do the columns and tables mean - 居住地 Residence - 國籍 Nationality - 性別 Gender - 年齡 Age - 職業 Occupation - 華僑外籍 Overseas Chinese or Foreigners - 來臺目的 Purpose of visit - 停留夜數 Length of stay - 交通工具及入境港口 Mode of Transport and Port of Entry - 匯率 Exchange Rate - where was the data from - 交通部民用航空局 - 政府資料開放平台 - 台灣期貨交易所 - 交通部觀光局觀光統計資料庫 - other information about your data (e.g. will it be updated in the future?) - it updates monthly - The source of your data - link to your data source - 出國資料 from 交通部觀光局觀光統計資料庫 - https://stat.taiwan.net.tw/outboundSearch - 來臺資料 from 交通部觀光局觀光統計資料庫 - https://stat.taiwan.net.tw/inboundSearch - 觀光外匯收入統計 from 政府資料開放平台 - https://data.gov.tw/dataset/8589 - 每日外幣參考匯率 from 臺灣期貨交易所 - https://www.taifex.com.tw/cht/3/dailyFXRate - 桃園國際機場定期航班 from 政府資料開放平台 - https://data.gov.tw/dataset/7869 - 民航運輸常用統計資料 - https://www.caa.gov.tw/TransStatistics.aspx?a=1089&lang=1 ### Schema - 資料皆從 98年1月 到 109年4月 #### 主 table | Field | Type | Null | Key | | -------- | ------- | ---- | --- | | **年** | int | NO | PRI | | **月** | int | NO | PRI | | **國家名稱** | varchar | NO | PRI | | 英文國名 | varchar | | | | Field | Type | Null | Key | | -------- | ------- | ---- | --- | | **國家名稱** | varchar | NO | PRI | | 幣別 | varchar | NO | | | ISO | varchar | NO | | #### Table: 出國旅客 - 年齡 | Field | Type | Null | Key | | -------- | ------- | ---- | --- | | **年** | int | NO | PRI | | **月** | int | NO | PRI | | **國家名稱** | varchar | NO | PRI | | 1-12歲 | int | | | | 13-19歲 | int | | | | 20-29歲 | int | | | | 30-39歲 | int | | | | 40-49歲 | int | | | | 50-59歲 | int | | | | 60歲以上 | int | | | - 性別 | Field | Type | Null | Key | | -------- | ------- | ---- | --- | | **年** | int | NO | PRI | | **月** | int | NO | PRI | | **國家名稱** | varchar | NO | PRI | | 男 | int | | | | 女 | int | | | - 交通工具及出境港口 | Field | Type | Null | Key | | -------- | ------- | ---- | --- | | **年** | int | NO | PRI | | **月** | int | NO | PRI | | **國家名稱** | varchar | NO | PRI | | 飛機_松山 | int | | | | 飛機_桃園 | int | | | | 飛機_臺中 | int | | | | 飛機_高雄 | int | | | | 飛機_其他 | int | | | | 輪船_基隆 | int | | | | 輪船_臺中 | int | | | | 輪船_高雄 | int | | | | 輪船_蘇澳 | int | | | | 輪船_花蓮 | int | | | | 輪船_金門 | int | | | | 輪船_馬祖 | int | | | | 輪船_其他 | int | | | - ~~目的地~~ *duplicated* | Field | Type | Null | Key | | -------- | ------- | ---- | --- | | **年** | int | NO | PRI | | **月** | int | NO | PRI | | **國家名稱** | varchar | | | | 人數 = 男+女 | int | | | #### Table: 入境旅客 - ~~國籍~~ *duplicated* | Field | Type | Null | Key | | ----- | ------- | ---- | --- | | **年** | int | NO | PRI | | **月** | int | NO | PRI | | **居住地** | varchar | NO | PRI | | 人數 = 男+女 | int | | | - 性別 | Field | Type | Null | Key | | -------- | ------- | ---- | --- | | **年** | int | NO | PRI | | **月** | int | NO | PRI | | **居住地** | varchar | NO | PRI | | 男 | int | | | | 女 | int | | | - 年齡 | Field | Type | Null | Key | | -------- | ------- | ---- | --- | | **年** | int | NO | PRI | | **月** | int | NO | PRI | | **居住地** | varchar | NO | PRI | | 1-9歲 | int | | | | 10-19歲 | int | | | | 20-29歲 | int | | | | 30-39歲 | int | | | | 40-49歲 | int | | | | 50-59歲 | int | | | | 60歲以上 | int | | | - 職業 | Field | Type | Null | Key | | -------- | ------- | ---- | --- | | **年** | int | NO | PRI | | **月** | int | NO | PRI | | **居住地** | varchar | NO | PRI | | 商人 | int | | | | 專門技術 | int | | | | 文化工作 | int | | | | 家管退休 | int | | | | 軍公職 | int | | | | 其他職業 | int | | | - 目的 | Field | Type | Null | Key | | -------- | ------- | ---- | --- | | **年** | int | NO | PRI | | **月** | int | NO | PRI | | **居住地** | varchar | NO | PRI | | 業務 | int | | | | 觀光 | int | | | | 探親 | int | | | | 會議 | int | | | | 求學 | int | | | | 展覽 | int | | | | 醫療 | int | | | | 其他 | int | | | - 華僑/外籍 | Field | Type | Null | Key | | -------- | ------- | ---- | --- | | **年** | int | NO | PRI | | **月** | int | NO | PRI | | **居住地** | varchar | NO | PRI | | 華僑 | int | | | | 外籍 | int | | | - 交通工具及入境港口 | Field | Type | Null | Key | | -------- | ------- | ---- | --- | | **年** | int | NO | PRI | | **月** | int | NO | PRI | | **居住地** | varchar | NO | PRI | | 飛機_松山 | int | | | | 飛機_桃園 | int | | | | 飛機_臺中 | int | | | | 飛機_高雄 | int | | | | 飛機_其他 | int | | | | 輪船_基隆 | int | | | | 輪船_臺中 | int | | | | 輪船_高雄 | int | | | | 輪船_花蓮 | int | | | | 輪船_金門 | int | | | | 輪船_馬祖 | int | | | | 輪船_其他 | int | | | #### Table: 外匯 - 原始 | Field | Type | Null | | -------------- | ------ | ---- | | **年** | int | | | **月** | int | | | **日** | int | NO | | 美元/新台幣 | double | | | 人民幣/新台幣 | double | | | 歐元/美元 | double | | | 美元/日幣 | double | | | 英鎊/美元 | double | | | 澳幣/美元 | double | | | 美元/港幣 | double | | | 美元/人民幣 | double | | | 美元/南非幣 | double | | | 紐幣/美元 | double | | ```graphviz digraph{ node [shape=diamond] 出國旅客 入境旅客 node [shape=square] 出國旅客->性別 出國旅客->交通工具及出境港口 出國旅客->年齡 入境旅客->國籍 subgraph Rel0 { node [shape=oval] edge [dir=none, color=black] 年齡->年 年齡->月 年齡->國家名稱 年齡->"1-12歲" 年齡->"13-19歲" 年齡->"20-29歲" 年齡->"30-39歲" 年齡->"40-49歲" 年齡->"50-59歲" 年齡->"60歲以上" } subgraph Rel1 { node [shape=oval] edge [dir=none, color=black] 性別->年 性別->月 性別->國家名稱 性別->男 性別->女 } subgraph Rel2 { node [shape=oval] edge [dir=none, color=black] 交通工具及出境港口->年 交通工具及出境港口->月 交通工具及出境港口->國家名稱 交通工具及出境港口->飛機_松山 交通工具及出境港口->飛機_桃園 交通工具及出境港口->飛機_臺中 交通工具及出境港口->飛機_高雄 交通工具及出境港口->飛機_其他 交通工具及出境港口->輪船_基隆 交通工具及出境港口->輪船_臺中 交通工具及出境港口->輪船_高雄 交通工具及出境港口->輪船_蘇澳 交通工具及出境港口->輪船_花蓮 交通工具及出境港口->輪船_金門 交通工具及出境港口->輪船_馬祖 交通工具及出境港口->輪船_其他 } subgraph Rel3 { node [shape=oval] edge [dir=none, color=black] 國籍->居住地 國籍->_國籍 } } ``` ## Application Design ### Main idea - the purpose of your application - 統整旅遊相關數據 - 了解來台旅客與國人出國的旅遊模式 - 統整金融(匯率)相關資料 - 綜觀國際金融變化 - 統整金融(匯率)對於國人出國旅遊(航班出境)之關係 - 探討金融(匯率)與國人出國旅遊(航班出境)是否具關連性 - 統整金融(匯率)對於外籍人士來台旅遊(航班入境)之關係 - 探討金融(匯率)與外籍人士來台旅遊(航班入境)是否具關連性 ### Functionality - what kind of information will be presented to users - 查詢旅遊相關數據 - 查詢金融(匯率)相關資料 - 查詢金融(匯率)對於國人出國旅遊(航班出境)之關係 - 查詢金融(匯率)對於外籍人士來台旅遊(航班入境)之關係 - what kind of interaction will be available - scrolling table to select what to query. - scrolling table to select in what order to display. - Allow users to type in the number of data to display in one query. - Default query if the user doesn't explicitly ask for something. - what kind of data will users be able to insert and update - Insert user's query history or useful query tables. (And maybe suggest related subjects) ### Interface - what will be the platform (website, mobile devices app, PC program etc.) - website - expected interface look (use figure or text to explain) - scrolling tables ## Work Plan ### Time Schedule | Dates | Goals | | ----- | -----------------------------------------| | 04/20 | Proposal | | 04/27 | Preprocess data, find primary keys | | 05/04 | Create the tables | | 05/11 | Design Basic Querys | | 05/18 | Design Advanced (Default) Querys | | 05/25 | Design functions of interation | | 06/01 | Interface | | 06/08 | Connect Back-end with Front-end | | 06/15 | Improve functions of the website | | 06/22 | Chcek the website, final report | ### Discussion - HackMD: https://hackmd.io/@o6py54BOTpWML_eLeVy9_g/rJKt6D3d8/edit - Demo video: 1. data 2. 展示基本 select 功能 ( 總人數、成長率、排序 ) 3. 展示 history 功能 4. 展示 insert 功能 5. 展示 delete 功能 6. 展示 update 功能 ### Repo - github : https://github.com/Database-Project-with-travel/Database_Project ## Other Link - github : https://github.com/Database-Project-with-travel/Database_Project - mysql load data : https://stackoverflow.com/questions/39918509/mysql-load-data-local-infile-specify-columns-value-depending-on-file https://stackoverflow.com/questions/27703098/load-data-local-infile-with-if-statement ## Problem Solving - ONLY FULL GROUP BY: `set global sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';` - History ```php $stmt = $conn->prepare("insert into user_history (query_sql) values (\"".$finalsql."\");"); $stmt->execute(); ```