假设我有Tutors
谁online webclasses
并创建learning packs
。 online webclasses
和learning packs
都可以通过students
评级,最后tutor's
评级是他的classes
和packs
上的所有评级的简单平均值。Mysql - 一个简单的数据库设计问题
这是我们目前Ratings
表的表结构 -
CREATE TABLE IF NOT EXISTS `Ratings` (
`id_rating` int(10) unsigned NOT NULL auto_increment,
`id_teacher` int(10) unsigned default NULL COMMENT 'the teacher who created the class/pack',
`id_lp` int(10) unsigned default NULL COMMENT 'the id of the learning pack',
`id_wc` int(10) NOT NULL default '0' COMMENT 'the id of the webclass',
`id_user` int(10) unsigned NOT NULL default '0' COMMENT 'the user who has rated',
`rate` int(10) unsigned NOT NULL default '0',
`cdate` timestamp NOT NULL default CURRENT_TIMESTAMP,
`udate` timestamp NULL default NULL,
PRIMARY KEY (`id_rating`),
KEY `Ratings_FKIndex1` (`id_user`),
KEY `id_lp` (`id_lp`),
KEY `id_wc` (`id_wc`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
目前,这两个类和包装收视率进入同一个表(id_wc
和id_lp
相应输入 - 输入一个,另一个是每个评级记录为NULL
)。
所以,我的问题是 -
这是正确的架构或者是更好地保持class
和pack
评级分开?为什么或者为什么不?对于class
和pack
评分,我需要完全相同数量的Rating
表格字段。
我想,如果分类和分级评分是分开找到的,那么单独的表格会减少要查找的记录数量。但是,因为在我们的情况下只需要导师评级(涉及班级和包),这就是为什么所有评级都放在一起的原因。
使用mySQL工作台,它甚至是由mysql开发人员制作的。 – 2011-01-19 18:36:29