我是否应该标准化用户的profile_image_url链接和字段,例如profile_background_color,以便用户可以自定义他们的个人资料?
只有一个User类就可以处理所有的事情。
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
}在规模、性能、修改方面,哪一个更好?
发布于 2011-07-18 01:29:48
我不会担心的。拆分表将导致较小的select,但这些只是较短的字符串,因此引入比所需更多的数据的成本很小。Joins可能很昂贵,但同样,这些都是简单的连接。
另一种选择是将所有内容都放在一个表中,但只在代码中使用组件在逻辑上将类拆分为三个。请参阅http://grails.org/doc/latest/guide/5.%20Object%20Relational%20Mapping%20%28GORM%29.html#5.2.2%20Composition%20in%20GORM
https://stackoverflow.com/questions/6725404
复制相似问题