我阅读了以下关于Domain Model设计模式和Data Mapper设计模式的文章:
对于one-to-one关系来说,这是相当容易的。有人能向我解释我如何组织many-to-many支持吗?
例如:我们有树表:posts、images和posts_href_images,其中最后一个表是支持posts和图像之间many-to-many关系的表。
发布于 2012-05-07 19:01:06
posts:
post_id | post data...
1 | "first"
2 | "second"
3 | "third"
4 | "fourth"
images:
image_id | image_data...
1 | "JPEG...."
2 | "PNG...."
3 | "GIF..."
4 | "BMP..."
posts_href_images:
post_id | image_id
1 | 2
1 | 3
2 | 1
2 | 2
3 | 3现在您有以下对:(第一,PNG),(第一,GIF),(第二,JPEG),(第二,PNG),(第三,GIF),并且您可以看到第四和BMP不在列表中,现在您看到了如何表示0、1或多个连接。
https://stackoverflow.com/questions/10485352
复制相似问题