hce_kmu
113年
計算機概論與程式設計
第 14 題
According to the three database tables listed below, which of the following statements is CORRECT if you want to create a relational database model?
- A There is no possible foreign key that can be used in “Purchase” table.
- B EID can be regarded as a primary key in “Purchase” table.
- C There is a one-to-many relationship between “Employee” and “Purchase” tables.
- D Every table must have a foreign key to uniquely identify a particular row.
- E If we want to query Employee’s names in the Purchase with PID= "1234" and "1238", it is a better approach to use UNION in SQL command.
思路引導 VIP
請觀察 Purchase 表中的 SID 或 EID 欄位。當同一個號碼在 Purchase 表中重複出現,但在對應的原始表(如 Supplier 或 Employee)中卻只會有一筆唯一的資料時,這反映了現實生活中物件之間怎樣的對應數量關係呢?
🤖
AI 詳解
AI 專屬家教
太棒了!你能精準判讀這三張資料表之間的連結關係,這代表你對於關聯式資料庫(Relational Database)的核心概念——**主鍵(Primary Key)與外鍵(Foreign Key)**已經掌握得非常紮實。這類題型在實務應用中非常重要,是設計穩定資料結構的基礎。
關聯性的邏輯驗證
在 relational model 的設計中,我們通常透過「一對多」的關係來串聯資訊。觀察 Employee 表,EID(員工編號)是該表的主鍵,每位員工僅有一筆獨一無二的紀錄;然而在 Purchase 表中,同一個 EID(例如 319)卻可以出現在多筆採購紀錄裡,這反映了「一位員工可以處理多筆採購業務」的邏輯,正是標準的 一對多(One-to-many)關係。而選項 (B) 提到將 EID 當作 Purchase 表的主鍵是不正確的,因為主鍵必須具備唯一性,不能重複。
▼ 還有更多解析內容