规范化更好或创建没有规范化的索引

时间:2014-05-20 10:45:53

标签: mysql database

我对数据库建模感到困惑,我的要求是

我想要实现

以下两个模式

1首先

colleges(id,name)
col_course_relation(colleges.id,courses.id)
courses(id,stream,degree,coursename)

课程示例可能

(1,"Engineering","Bachelor of Engineering","Computer Science & Engineering")
(2,"Engineering","Master of Engineering","Computer Science & Engineering")
(3,"Engineering","Bachelor of Technology,"Computer Science & Engineering")
(4,"Engineering","Master of Technology","Computer Science & Engineering")

为课程表使用普通表单是否更好,或者我可以为所有列创建索引

如果我进行规范化,则架构变为

2秒

colleges(id,name)
col_course_relation(colleges.id,courses.id)
stream(id,streamname)
degree(id,degreename,stream.id)
courses(id,coursename,degree.id)

或#3第三

colleges(id,name)
col_course_relation(colleges.id,courses.id,stream.id,degree.id)
stream(id,streamname)
degree(id,degreename)
courses(id,coursename)

但无论何时在UI中映射这些内容,都会根据程度自动选择流。

从性能和易于编写查询的角度来看,架构更好。将有大约5万所大学* 10门课程,所以我在思考和思考的原因问这个问题。

1 个答案:

答案 0 :(得分:1)

请正常化。