[英]User Image/Profile fields - Database normalization - Social Networking - Grails
我應該規范用戶profile_image_url
鏈接和字段,例如用戶可以自定義他們的配置文件的profile_background_color
嗎?
擁有一個用戶 class 與一切。
class User {
String profile_big_url
String profile_thumb_url
String profile_background_color
String profile_text_color
String profile_link_color
String profile_sidebar_fill_color
String profile_sidebar_border_color
String profile_background_image_url
String profile_background_tile
}
或三班
class User{
Photo photo
Profile profile
}
class Photo{
User user
String profile_big_url
String profile_thumb_url
}
class Profile{
User user
String profile_background_color
String profile_text_color
String profile_link_color
String profile_sidebar_fill_color
String profile_sidebar_border_color
String profile_background_image_url
String profile_background_tile
}
在規模、性能、修改方面哪個更好?
我不會擔心的。 拆分表會導致更小的select
s 但這些只是短字符串,因此提取比您需要的更多數據的成本很小。 連接可能很昂貴,但同樣,這些將是簡單的。
另一種方法是將所有內容都放在一個表中,但使用組件將 class 在代碼中邏輯地拆分為三個。 見http://grails.org/doc/latest/guide/5.%20Object%20Relational%20Mapping%20%28GORM%29.html#5.2.2%20Composition%20in%20GORM
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.