我有表文件夾,其中列parent_id引用id如果該文件夾有父,如果不是,則parent_id爲null。這是好的解決方案,或者我需要額外的表格用於此連接或其他解決方案?外鍵可以爲空,如果可以的話,這個解決方案會有更大的時間執行嗎?外鍵null - 性能下降
table folder(
id int primary key, //primary key in my table
parent_id int references id, //foreign key on id column in same table
....
)
我認爲額外的表像表分機(id_column,id_folder,parent_id_folder)。列有很多空NULL時是否會有性能下降? – Jane 2010-10-22 17:43:10
你不應該有巨大的性能下降。你可以添加一個索引的外鍵,如果這有助於某些查詢... – 2010-10-22 17:46:23
謝謝,它有幫助! – Jane 2010-10-22 17:47:42