2012-09-27 87 views
0

假設我在學生和教師之間有多對多的關係,並且我爲此建立了一個應用程序,我將學生分配給教師,教師分配給學生。我可能希望我的數據正常化(我有一個教師集合和一個學生集合)。MongoDB性能與關係數據庫對於許多許多一對多

我想知道,在上述情況下(多對多),如果我要使用關係數據庫(如MySQL)而不是MongoDb,性能會更好嗎?一對多的性能如何?

回答

0

說實話,要看執行情況。在MySql中,它取決於你如何佈置模式並將其編入索引。

Flat DB存儲(Mongo)並不意味着您將自動獲得性能。這純粹是主觀的。

以下是基於描述的MySql中的示例。

create table teachers (teacher_id int Primary Key, teacher_name varchar(20)) 
create table students (student_id int Primary Key, student_name varchar(20)) 
create table teacher_student_assoc (assoc_id int Primary Key, teacher_id int, student_id int) create index on teacher_id and student_id 

除非你的MySQL數據庫是會得到上敲定(假設你的網站獲得100K打了一天)我不明白爲什麼你需要擔心性能。

你也可以實現memcacheif需要的。

祝你好運。