關於 Lookup 的使用,首先我們可以參考 FileMaker 的文件。
官方文件 是這樣寫的:
A lookup copies data from another table into a field in the current table. After data is copied, it becomes part of the current table (and remains in the table from which it was copied). Data copied to the current table doesn’t change automatically when the data in the other table changes.
適用場合:薪水、商品價格。
像是薪水、商品價格…等 Field「欄位」資料,在平常不會有變化,但是過一段時間之後可能需要調整並被另一個 Table「表格」所取用的時候,我們希望有關這個資料的「舊」記錄(若有舊記錄的話)不會被改變,只有「新產生」的記錄會取用調整過的新資料。
像這樣的方式,就很適合用 Lookup 方式來表現一個 Fileld「欄位」資料。
舉個例子
假設這個 SOHO 攝影師自己的工作檔案裡,替 Vogue 拍照的薪水原本是 £ 45 / hr(每小時 45 英鎊),2016年10月1日以後調升為 £ 50 / hr。我們就可以用 Lookup 的方式設計薪水 (wage) 這個欄位。
Lookup 如何設計及操作
- 薪水 (Wage) 的欄位呈現於 “JobDetails" Table,開啟資料庫管理工具 Manage Database,選擇 Table: JobDetails,我們可以看到薪水的欄位命名為 LookupWage(表示我們將這個欄位設計成 Lookup 形式),點兩下進入設定。
- Auto-Enter > Looked-up value > Specify,進入設定 Lookup
- Starting with table: “JobDetails"
薪水 (Wage) 呈現在現在這個 Table “JobDetails" - Lookup from related table: “Employers_jobs"
薪水 (Wage) 資料實際上是從相關的 Employers_Jobs 拷貝 (lookup) 過來 - Copy value from field:"::Wage"
- do not copy
完成了 Lookup 的欄位設定,這樣就可以達到資料拷貝的功能,讓新的表單可以去運用這些 Lookup 的資料,這邊需要特別注意的一點:
- Lookup 的兩個表單之間需要設定相關 Relationship
其他案例,Database Pros 介紹如何詳細操作
(用ZipCode當例子,更加清楚的應用 Lookup)
Lookups Part 1
Lookups Part 2
Lookups Part 3