I was reading the symfony2 mongodb documentation recently, and I felt a little confused about how to use it.
Mongodb has odm one-to-one, one-to-many, many-to-many relationship mapping similar to mysql orm, which is also more convenient to use.
But if you use mysql and mongodb in combination, to get the mongodb data from mysql, according to the doctrine one-to-one official document, you need to associate mysql and mongodb through the subscriber and LifecycleEventArgs events.
There are no detailed examples for one-to-many and many-to-many. Later, it was discovered that when using one-to-many and many-to-many, an intermediate table needs to be generated in mysql and mongodb. Through the LifecycleEventArgs event, the intermediate table becomes a bridge for communication between mysql and mongodb
So the maintenance of this intermediate table is more troublesome. For example, if you delete mongodb data, you must also update the intermediate table. In addition, if there are many tables associated with two databases, wouldn't there also be many intermediate tables? ?
For smyfony2, use MySQL and mongodb in combination. Is it better to use a single database? ? ? If the two are used in combination, the stored data must not be highly dependent? ? ? In that case, does it feel cumbersome to use mysql and mongodb on the doctrine official website? ?
要简单可靠肯定是应该将各业务分别放到单一的存储里;Doctrine提供了跨类型存储的面对对象操作界面,并不是说推荐这么做。
既然都已经在不同的存储里了,用API来操作是比较合适的。