PHPのフレームワーク「CakePHP」を使用していると 「あれ?どっちだっけ?」 ということがたまにあります。何に迷うのかは色々とあるのですが、その中の1つがアソシエーションです。 アソシエーションとはテーブルとテーブルを結びつけるもので、Accessの場合、リレーションとよく言います(あまりAccessと比較する人もいませんが(^_^;))。 CakePHPではアソシエーションに hasOne (1対1) hasMany (1対多) belongsTo (多対1) hasAndBelongsToMany (多対多) の4種類があり、特によく使用されるのが、hasManyとbelongsToではないでしょうか? このhasManyとbelongsToが私の頭の中では1対多だったか多対1だったかがすぐ忘れてしまうんです。 「英語読めばわかるんじゃないの?」 といわれそうですが、それでも、頭