一つのテーブルから、複数のリレーションを張るスキーマの書き方
口でうまく言えないので、例を絵で説明すると
コメントテーブルは、コメントしたユーザのidとコメントされたユーザのidを持っている。を表す方法です。
User: columns: id: type: integer(4) primary: true autoincrement: true username: string Comment: columns: id: type: integer(4) primary: true autoincrement: true commenter_id: integer(4) commented_user_id: integer(4) relations: Commenter: class: User local: commenter_id foreign: id CommentedUser: class: User local: commented_user_id foreign: id
別名付ければいいわけです。
参考にしたページ
DB操作する場合も、この別名で操作できます。
CommentテーブルのCommenterとUserテーブルのidでJoinとか