2014-10-09 63 views
0

你好,我不確定這是否是一個好問題,但在這裏,我很困惑我將如何使我的牙圖數據庫的數據結構。我有做的數據結構是這樣齒形圖的數據庫結構

teeth_table 
teeth_id (Primary key) 
teeth_1 (These are 32 tooth) 
until teeth_32 (These are 32 tooth) 
patient_id (Foreign key connected to the patient table) 

我的第二個計劃是讓每個牙齒的各個表的第一本以爲(這將花費大量的時間,我猜?)

tooth01_table 
tooth_id 
tooth_name 
tooth_condition 
tooth_recommendation 
tooth_treatment 
patient_id 

這就是所有我想,我的 的計劃是做一個表,其中會顯示以下當病人從下拉列表中

牙齒選擇牙齒|條件|推薦|治療

那麼你們認爲什麼是牙齒圖表數據庫的好設計?

牙齒圖是這樣的

http://www.mouthandteeth.com/img/FDI-tooth-numbering-system.gif

回答

1

我建議如下設計:有

CREATE TABLE tooth (
    tooth_code char(2)  NOT NULL PRIMARY KEY, 
    -- teeth don't have real numbers 
    -- it is a qudrant number + tooth number combination 
    -- therefore char(2) 
    tooth_cat varchar(50) NOT NULL 
    CHECK (tooth_cat IN ('incisor','canine','premolar','molar') 
    -- though I find this info redundant, 
    -- category can be deduced from tooth_code 
); 

CREATE TABLE mounth (
    patient_id int4  NOT NULL, 
    tooth_code char(2) NOT NULL, 
    inspect_dt timestamp with time zone NOT NULL, 
    condition text, 
    suggestion text, 
    treatment text, 
    PRIMARY KEY (patient_id, tooth_code, inspect_dt), 
    FOREIGN KEY (patient_id) REFERENCES patient, 
    FOREIGN KEY (tooth_code) REFERENCES tooth 
); 
  1. 你應該用牙齒代碼和surronding字典說明
  2. 每個齒屬於一些病人,因此它們一定要同時
  3. 也,在系統入口的檢查過程中出現,因此PK由3個欄爲表mouth
  4. 我用tooth_code,「因爲id通常是指數值,但我們在這裏沒有實際的數字,儘管它們看起來一樣
  5. 我不太喜歡mouth,也許patient_inspections或類似的會更好的匹配。
  6. 英語不是我的母語,所以在適用的地方選擇更好的名字。
+0

這看起來更好,謝謝你的幫助。 – piece 2014-10-09 11:45:27